一个简单的android程序问题

时间:2012-04-29 17:34:53

标签: android

代码:

    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();

}
  }

正如大家们所看到的,这是一个非常简单的程序,它会显示一个闪屏,然后会在浏览器中打开网址。这里的一切都很好。现在通过使用后退按钮我退出应用程序。但是当我尝试按下已安装的应用程序图标时,系统会立即向我致敬"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

2 个答案:

答案 0 :(得分:0)

如果你正在使用冰淇淋三明治,(我记得在SO中的某个地方阅读)不仅权限必须在自己的标签中,应用程序不能同时具有属性“android.permission.INTERNET”。所以只需从应用程序节点中删除它并尝试...

答案 1 :(得分:0)

尝试删除:

android:permission="android.permission.INTERNET"

从这一部分:

<application
android:icon="@drawable/app_icon"
android:label="@string/app_name" android:permission="android.permission.INTERNET"  android:description="@string/appdescription">

但请将其留在清单的另一部分。