If the application is already installed in the device the application is open automatically.
Otherwise install the particular application.
Otherwise install the particular application.
public class Example extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Put the package name here... boolean installed = appInstalledOrNot("com.Ch.Example.pack"); if(installed) { //This intent will help you to launch if the package is already installed Intent LaunchIntent = getPackageManager() .getLaunchIntentForPackage("com.Ch.Example.pack"); startActivity(LaunchIntent); System.out.println("App is already installed on your phone"); } else { System.out.println("App is not currently installed on your phone"); } } private boolean appInstalledOrNot(String uri) { PackageManager pm = getPackageManager(); boolean app_installed; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); app_installed = true; } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed; } }
0 comments:
Post a Comment