[ 
https://issues.apache.org/jira/browse/CB-12351?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Aditya Goel updated CB-12351:
-----------------------------
    Security:     (was: Non-Public)

> Code works as normal app but not as a launcher app
> --------------------------------------------------
>
>                 Key: CB-12351
>                 URL: https://issues.apache.org/jira/browse/CB-12351
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugins
>    Affects Versions: 6.4.0
>         Environment: Android 4.4.2, Android Studio
>            Reporter: Aditya Goel
>            Priority: Blocker
>              Labels: easyfix, newbie
>   Original Estimate: 336h
>  Remaining Estimate: 336h
>
> Hi,
> Before starting, I wanted to say that this is the first time I am using jira 
> support for Apache Cordova. I don't even know if this is the right place or 
> if the issue I have is allowed here but I tried other means and found no 
> help. This is a very critical issue for me, any help will be highly 
> appreciated.
> I am making an Android Launcher using Cordova (let's call it myApp) and as 
> every launcher it should have an apps drawer. Clicking on any app icon should 
> launch that app.
> Let me now describe two scenarios.
> 1) Android launcher is the default launcher for the system and myApp is 
> installed as just any other app. In this case the code works fine, that is, 
> the other apps launch fine from the apps drawer in myApp.
> 2) myApp is the default launcher for the system. In this case, the code does 
> not work, that is, the other apps do not launch from the apps drawer in myApp 
> or may be they launch or close very very fast.
> This is the code I have:
> private void launchApp(final String packageName) {
>         final CordovaInterface mycordova = cordova;
>         final CordovaPlugin plugin = this;
>         Log.i("myApp", "Trying to launch app: " + packageName);
>         cordova.getThreadPool().execute(new Runnable() {
>             public void run() {
>                 try {
>                     Intent intent = new Intent("android.intent.action.MAIN");
>                     intent.addCategory("android.intent.category.LAUNCHER");
>                     final ComponentName cn = new ComponentName(packageName, 
> cordova.getActivity().getApplicationContext().getPackageManager().getLaunchIntentForPackage(packageName).getComponent().getClassName());
>                     intent.setComponent(cn);
>                     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
>                     
> cordova.getActivity().getApplicationContext().startActivity(intent);
>                 } catch (ActivityNotFoundException e) {
>                     Log.e("myApp", "Error: Activity for package" + 
> packageName + " was not found.");
>                     e.printStackTrace();
>                 } catch (Exception e) {
>                     Log.e("myApp", "Error: " + e.getMessage());
>                     e.printStackTrace();
>                 }
>             }
>         });
>     }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to