本文介绍了任务锁定时,Android运行另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用程序设置为设备所有者,并且在调用startLockTask()时屏幕固定.我现在的问题是,当我尝试使用此方法运行另一个应用程序时:

I set my application as a device owner and the screen is pinning when i call startLockTask() . my problem now when i try to run another application by using this method :

Intent i = getPackageManager().getLaunchIntentForPackage("com.example.test");
startActivityForResult(i,Intent.FLAG_ACTIVITY_NEW_TASK);

(什么都没有发生)我必须做些什么才能使其运行?

(nothing happen)what i have to do to make it run?

我尝试添加

 dpm.setLockTaskPackages(deviceAdmin, new String[] { getPackageName() ,"com.example.test"});

它也不会启动.

推荐答案

您应检查设备上安装了applicationId的应用程序.例如,在您的情况下, applicationId com.example.test.如果未安装该应用程序,则可以将用户带到市场或让他们选择一个应用程序.

You should check the app with an applicationId is installed on the device. for example in your case the applicationId is com.example.test.If the app was not installed, you can bring user to a market or let them choose an app.

String packageName = "com.example.test";
.
.
.
Intent i = context.getPackageManager().getLaunchIntentForPackage(packageName);
if (i == null) {
    i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse("market://details?id=" + packageName));
    // Open app in google play store:
    // i.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName));
}
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);

这篇关于任务锁定时,Android运行另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 16:54