代码:
setContentView(R.layout.splashscreen);
Thread timer = new Thread() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
intent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com/"));
startActivity(intent);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
this.finish();
}
}
正如你们所看到的,这是一个非常简单的程序,它会显示一个启动屏幕,然后会在浏览器中打开 URL。到这里为止一切都很好。现在通过使用后退按钮,我退出了应用程序。但是,只要我尝试按下已安装的应用程序图标,系统就会给我一个祝酒词"app is not installed on your phone"
。
当我检查正在运行的服务时,它总是在那里,我logcat
说:"Launcher does not have permission to launch the intent"
。
所以我的第一个问题:为什么我的应用程序一直在运行,尽管我已经finish()
在onPause()
方法中调用了?
Q2。此logcat
消息表明什么?
这是我的清单(猜你在想我没有添加uses-permission
互联网但我有):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.xyz.main"
android:versionCode="1"
android:versionName="1.0.1" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/app_icon"
android:label="@string/app_name" android:permission="android.permission.INTERNET" android:description="@string/appdescription">
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是logcat
:
04-29 23:17:56.745: I/ActivityManager(68): Starting activity: Intent {act=android.intent.action.MAIN cat[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }
04-29 23:17:56.745: W/ActivityManager(68): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity } from ProcessRecord{45cfc0f8 240:com.android.launcher/10025} (pid=240, uid=10025) requires android.permission.INTERNET
04-29 23:17:56.785: E/Launcher(240): Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }. Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity. tag=ApplicationInfo(title=ePost) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }
04-29 23:17:56.785: E/Launcher(240): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity } from ProcessRecord{45cfc0f8 240:com.android.launcher/10025} (pid=240, uid=10025) requires android.permission.INTERNET
04-29 23:17:56.785: E/Launcher(240): at android.os.Parcel.readException(Parcel.java:1247)
04-29 23:17:56.785: E/Launcher(240): at android.os.Parcel.readException(Parcel.java:1235)
04-29 23:17:56.785: E/Launcher(240): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
04-29 23:17:56.785: E/Launcher(240): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
04-29 23:17:56.785: E/Launcher(240): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.Launcher.startActivityForResult(Launcher.java:1053)
04-29 23:17:56.785: E/Launcher(240): at android.app.Activity.startActivity(Activity.java:2923)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.Launcher.startActivitySafely(Launcher.java:1462)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.AllApps2D.onItemClick(AllApps2D.java:178)
04-29 23:17:56.785: E/Launcher(240): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
04-29 23:17:56.785: E/Launcher(240): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
04-29 23:17:56.785: E/Launcher(240): at android.os.Handler.handleCallback(Handler.java:587)
04-29 23:17:56.785: E/Launcher(240): at android.os.Handler.dispatchMessage(Handler.java:92)
04-29 23:17:56.785: E/Launcher(240): at android.os.Looper.loop(Looper.java:123)
04-29 23:17:56.785: E/Launcher(240): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-29 23:17:56.785: E/Launcher(240): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 23:17:56.785: E/Launcher(240): at java.lang.reflect.Method.invoke(Method.java:521)
04-29 23:17:56.785: E/Launcher(240): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-29 23:17:56.785: E/Launcher(240): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-29 23:17:56.785: E/Launcher(240): at dalvik.system.NativeStart.main(Native Method)
04-29 23:17:59.855: W/KeyCharacterMap(240): No keyboard for id 0
04-29 23:17:59.855: W/KeyCharacterMap(240): Using default keymap: /system/usr/keychars/qwerty.kcm.bin