小言_互联网的博客

android 8.0 appwidget跳转apk进程失败

607人阅读  评论(0)

1.appwidget中没有界面,点击直接跳转到app无法启动

2.解决方法

1)新建一个EmptyActivity,activity中的finish界面

public class EmptyActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        finish();
    }
}

2)在跳转app之前,先跳转到这个空置的界面

//跳转空的activity
try {
   Intent emptyIntent = new Intent(context, EmptyActivity.class);
   emptyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   context.startActivity(emptyIntent);
} catch (Exception e) {
   Log.e(TAG, "EmptyActivity Intent e = " + e.toString());
}

//跳转app

Intent mapIntent = new Intent();
mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName componetName = new ComponentName( "xxx","xxxxActivity");
mapIntent.setComponent(componetName);
context.startActivity(mapIntent);

3.成功跳转


转载:https://blog.csdn.net/yangaiyu/article/details/102571290
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场