0

当我尝试在模拟器上运行我的应用程序时,不直接调用 LoginActivity 类,而当我通过 USB 在设备中运行时,它会抛出以下异常,

这是一个奇怪的行为,当我删除我的 LoginActivity splashActivity 类被调用并且应用程序因为未找到 loginactivity 而关闭时,当我作为 MainActivity 恢复启动时一切正常

[2012-11-22 16:59:57 - medeclinicv2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.kredence.medeclinicv2/.LoginActivity }

[2012-11-22 16:59:57 - medeclinicv2] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.kredence.medeclinicv2/.LoginActivity } from null (pid=5929, uid=2000) requires null

这是我的清单代码,我已经清理了我的项目

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.kredence.medeclinicv2"
    android:versionCode="2"
    android:versionName="1.0" >
   <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application
        android:icon="@drawable/ic_launcher" 
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".splashActivity"
            android:label="@string/app_name">
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
        <activity
            android:name=".LoginActivity"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            clearTaskOnLaunch = "true" />
        <activity
            android:name=".viewAppointment"
            android:icon="@drawable/minilogo"
            android:label="Schedule/View Appointment"
            android:windowSoftInputMode="adjustPan"
            clearTaskOnLaunch = "true">            
        </activity>
        <activity
            android:name=".scheduleActivity"
            clearTaskOnLaunch = "true"
            android:theme="@android:style/Theme.Black.NoTitleBar">            
        </activity>
        <activity
            android:name=".scheduleAppointment"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            clearTaskOnLaunch = "true">            
        </activity>
        <activity
            android:name=".reScheduleAppointment"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            clearTaskOnLaunch = "true">            
        </activity>
      <!--  <service android:name=".MainActivity"></service> --> 
       <service android:name="com.commonsware.cwac.updater.UpdateService"/>
       <receiver android:name="com.commonsware.cwac.updater.WakefulReceiver"/>
    </application>
</manifest>

飞溅活动

package com.kredence.medeclinicv2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class splashActivity extends Activity {

    protected int _splashTime = 5000;
    private Thread splashTread;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        final splashActivity sPlashScreen = this;
        // thread for displaying the SplashScreen
        splashTread = new Thread() {

            @Override
            public void run() {
                try {
                    synchronized (this) {
                        wait(_splashTime);
                    }
                } catch (InterruptedException e) {} finally {
                    finish();
                    Intent i = new Intent();
                    i.setClass(sPlashScreen, LoginActivity.class);
                }
            }
        };
        splashTread.start();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            synchronized (splashTread) {
                splashTread.notifyAll();
            }
        }
        return true;
    }
}
4

1 回答 1

0

查看您的 Android 清单代码。

通常,java.lang.SecurityException是因为您可以输入两个指向同一活动的条目。删除第二个,你应该很高兴。

于 2012-11-22T12:42:51.783 回答