用Android Intent打开TikTok

时间:2018-11-17 00:35:05

标签: android android-intent

使用以下代码时,出现错误:E / AndroidRuntime:致命异常:main。可能是我的TikTok软件包名称错误,但是“ com.ss.android.ugc.trill”是我可以找到的唯一软件包名称。像其他标准软件包名称一样,“ com.tiktok.android”也不起作用。

            try {

                Intent tiktokIntent = mContext.getPackageManager().getLaunchIntentForPackage("com.ss.android.ugc.trill");
                startActivity(tiktokIntent);

            } catch (ActivityNotFoundException e) {

                Toast.makeText(mContext, String.valueOf(e), Toast.LENGTH_SHORT).show();

            }

更多错误信息:

E / Android运行时:致命异常:主要 java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'boolean android.content.Intent.migrateExtraStreamToClipData()'         在android.app.Instrumentation.execStartActivity(Instrumentation.java:1524)         在android.app.Activity.startActivityForResult(Activity.java:4399)         在android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)         在android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)         在android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:233)         在android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:825)         在android.support.v4.app.FragmentActivity $ HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:939)         在android.support.v4.app.Fragment.startActivity(Fragment.java:1002)         在android.support.v4.app.Fragment.startActivity(Fragment.java:991)         在com.example.ricks.projectone.Profile.ProfileFragment $ 13.onClick(ProfileFragment.java:537)         在android.view.View.performClick(View.java:6205)         在android.view.View $ PerformClick.run(View.java:23653)         在android.os.Handler.handleCallback(Handler.java:751)         在android.os.Handler.dispatchMessage(Handler.java:95)         在android.os.Looper.loop(Looper.java:154)         在android.app.ActivityThread.main(ActivityThread.java:6682)         在java.lang.reflect.Method.invoke(本机方法)         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1520)         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

0 个答案:

没有答案