Intent to Hidden Application on Android

早过忘川 提交于 2019-12-24 03:33:05

问题


I have two application. I want to intent to the second one from the first one. But the second application must be launched from first one. So i have to hide the second one's icon.

When i delete the category tag from the second one's manifest.xml, icon is disappearing. But this time i can't launch the second app from the first app with intent.

This is how i tried to intent:

Intent openvideo = getPackageManager().getLaunchIntentForPackage("air.deneme");
startActivity(openvideo);

How can i handle it?

Both of the applications are view based, they aren't background applications.


回答1:


ComponentName lComponentName= new ComponentName(yourPackageNameOFApplication2, yourPackageNameOFApplication2.YourMainActivityOfApplication2);

        try {
            Intent i = new Intent(Intent.ACTION_MAIN);
            i.setComponent(lComponentName);
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(i);
        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
            // Write Toast , we will have an exception if the second application is not installed
        }


来源:https://stackoverflow.com/questions/20771767/intent-to-hidden-application-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!