意图在Android上隐藏的应用程序 [英] Intent to Hidden Application on Android

查看:147
本文介绍了意图在Android上隐藏的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序。欲意图从第一个第二个。但第二个应用程序必须从第一个推出。所以我不得不隐藏第二个图标。

当我删除第二个的manifest.xml的类别标签,图标正在消失。但这次我不能从意图第一个应用程序启动第二个应用程序。

这是我怎么想的意图:

 意图openvideo = getPackageManager()getLaunchIntentForPackage(air.deneme);
startActivity(openvideo);

我该如何处理呢?

这两个应用程序都是基于认为,他们不是后台应用程序。


解决方案

 组件名lComponentName =新的组件名(yourPackageNameOFApplication2,yourPackageNameOFApplication2.YourMainActivityOfApplication2);        尝试{
            意图I =新意图(Intent.ACTION_MAIN);
            i.setComponent(lComponentName);
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(ⅰ);
        }赶上(ActivityNotFoundException E){
            e.printStackTrace();
            //写吐司,我们将有一个例外,如果没有安装第二个应用程序
        }

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.

解决方案

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
        }

这篇关于意图在Android上隐藏的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆