top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Open other app from webview in Android?

+3 votes
570 views

Hi, I want to open another applications like Facebook, google play etc., while user clicks links in the webview of my application. I have given facebook.com link to the buttons. However app doesn't load by clicking that. Please help.

posted Jun 29, 2016 by Abhijit

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+3 votes
 
Best answer

You have to add custom WebViewClient to be able to handle clicks on link buttons of WebView directly in Android Java.

webView.setWebViewClient(new CustomWebViewClient());

Override shouldOverrideUrlLoading method in class,

public boolean shouldOverrideUrlLoading(final WebView webView, final String url) {
    if (url.startsWith("<app.url or something to identify>://")) {
        final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        // This opens other apps
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        activity.startActivity(intent);
        return true;
    }  
    return false;
}
answer Jul 4, 2016 by Vinod Kumar K V
+1 vote

Hi,you need to use intents to open facebook ,google play etc to open them when users click on links given in webview:

Intent intent = new Intent();
intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth");
intent.putExtra("client_id", applicationId); // authorizes an  action, taken from facebook API
mAuthActivityCode = activityCode;
activity.startActivityForResult(intent, activityCode);

Similarly you can do this for other apps by replacing com.facebook.katana that is package name of app.

answer Jun 29, 2016 by Shivam Kumar Pandey
Similar Questions
+3 votes

It seems to be working weird, any pointer.

+2 votes

Am new to Android. I am doing android app in that i was loading existing web pages into my App using Webview.I did successfully for loading the web pages using Webview.But i need to delete some part of web page content before loading into web view.

Please help me with some sample codes.

Thanks.

+1 vote

In my system application for the latest jeally bean ( 4.3 ), signed with the fitting platform certificate running as android.uid.system. In my manifest, I added the permissions READ_FRAME_BUFFER, ACCESS_SURFACE_FLINGER.

In my app, I'm able to access the SurfaceFlinger service via the ScreenShotClient ( c++ ). Accessing the /dev/graphics/fb0 device directly ( also using native code, c++ ) via open always failed with a permission error.

I wrote an little command line tool, which is able to open the /dev/graphics/fb0. For sure my command line tool is running as root user, and my app is running as system user.

ls -l -a /dev/graphics/fb0 crw-rw---- root graphics 29, 0 2013-09-30 07:31 fb0

For my understanding only the root user, or a member of the graphics group can access the fb0. For my understanding the READ_FRAME_BUFFER permission, is exactly for accessing /dev/graphics/fb? Can someone please give me a hint?

+6 votes

In android generally when an app is installed, the PackageInstallerActivity and PackageManagerService make sure to assign the supplementary gid's to the app. This determines the level of access when an app is invoked everytime.

I just wanted to confirm if any verification process takes place in the runtime from packagemanager or any other service for that matter.

The app is granted the corresponding access from the gid's that should get it running technically and Packagemanager will only come into picture incase of updating the app.

Is my understanding correct?

+3 votes

how can install apk through ADB in android device.

...