我添加了一个函数,“如果单击列表元素,则执行浏览器应用程序”。在运行浏览器应用程序时按主页按钮并执行另一个应用程序问题是当返回我的应用程序时,发生错误“无法启动活动组件信息”。
对不起,我的英语很弱。
我的应用正在使用ViewPager和Fragment。
问题一步。
我的应用:点击列表元素
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(intent);
日志
03-25 22:26:17.261: E/AndroidRuntime(28894): FATAL EXCEPTION: main
03-25 22:26:17.261: E/AndroidRuntime(28894): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.temp.example/com.temp.example.Main}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.temp.example.Temp: make sure class name exists, is public, and has an empty constructor that is public
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread.access$700(ActivityThread.java:143)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.os.Looper.loop(Looper.java:137)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread.main(ActivityThread.java:4950)
03-25 22:26:17.261: E/AndroidRuntime(28894): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 22:26:17.261: E/AndroidRuntime(28894): at java.lang.reflect.Method.invoke(Method.java:511)
03-25 22:26:17.261: E/AndroidRuntime(28894): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)
03-25 22:26:17.261: E/AndroidRuntime(28894): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
03-25 22:26:17.261: E/AndroidRuntime(28894): at dalvik.system.NativeStart.main(Native Method)
03-25 22:26:17.261: E/AndroidRuntime(28894): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.temp.example.Temp: make sure class name exists, is public, and has an empty constructor that is public
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.support.v4.app.Fragment.instantiate(Fragment.java:413)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1790)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213)
03-25 22:26:17.261: E/AndroidRuntime(28894): at com.temp.example.Main.onCreate(Main.java:58)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.Activity.performCreate(Activity.java:5177)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
03-25 22:26:17.261: E/AndroidRuntime(28894): ... 11 more
03-25 22:26:17.261: E/AndroidRuntime(28894): Caused by: java.lang.InstantiationException: can't instantiate class com.temp.example.Temp; no empty constructor
03-25 22:26:17.261: E/AndroidRuntime(28894): at java.lang.Class.newInstanceImpl(Native Method)
03-25 22:26:17.261: E/AndroidRuntime(28894): at java.lang.Class.newInstance(Class.java:1319)
03-25 22:26:17.261: E/AndroidRuntime(28894): at android.support.v4.app.Fragment.instantiate(Fragment.java:402)
03-25 22:26:17.261: E/AndroidRuntime(28894): ... 18 more
如果您知道解决方案,请告诉我。
感谢您的阅读。
答案 0 :(得分:1)