2015-03-31 170 views
-2

我已將第一個從MainActivity運行的活動更改爲另一個活動。我通過編輯Android清單並複製:更改活動啓動意向錯誤

<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

我想要的活動。現在,當我在我的android設備上運行或調試我的應用程序時,它已成功安裝,但它不會像以前那樣自動啓動,因爲我必須單擊該圖標,並且出現下面的錯誤,並且如果我在模擬器中運行它,正確的活動僅在第一次安裝後,它只是忽略該活動,並始終開始MainActivity

請幫忙。

Launching application: com.package/com.package.MainActivity. 
DEVICE SHELL COMMAND: am start -D -n "com.package/com.package.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=si.comtron.tronpos/.MainActivity } 
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=si.comtron.tronpos/.MainActivity } from null (pid=3636, uid=2000) not exported from uid 10104 
at android.os.Parcel.readException(Parcel.java:1465) 
at android.os.Parcel.readException(Parcel.java:1419) 
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:2211) 
at com.android.commands.am.Am.runStart(Am.java:680) 
at com.android.commands.am.Am.onRun(Am.java:270) 
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47) 
at com.android.commands.am.Am.main(Am.java:76) 
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) 
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243) 
at dalvik.system.NativeStart.main(Native Method) 

我的整個清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    package="si.comtron.tronpos" > 
<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="19" /> 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.BLUETOOTH" /> 
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 

<uses-feature android:name="android.hardware.usb.host" /> 

<!-- calendar --> 
<uses-permission android:name="android.permission.READ_CALENDAR" /> 
<uses-permission android:name="android.permission.WRITE_CALENDAR" /> 

<!-- camera --> 
<uses-permission android:name="android.permission.CAMERA" /> 

<uses-feature android:name="android.hardware.camera" /> 
<uses-feature android:name="android.hardware.camera.autofocus" /> 

<!-- client --> 
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> 
<!-- Authenticator --> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> 
<!-- Shortcut --> 
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 
<!-- Wifi --> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 

<android:uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<android:uses-permission 
    android:name="android.permission.READ_EXTERNAL_STORAGE" 
    android:maxSdkVersion="18" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" 
    tools:replace="android:icon,android:theme" > 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:launchMode="singleTask" 
     android:screenOrientation="sensor" 
     android:windowSoftInputMode="adjustNothing" > 
    </activity> 
    <activity 
     android:name=".bluetooth.DeviceListActivity" 
     android:configChanges="orientation|keyboardHidden|screenSize" 
     android:label="@string/select_device" 
     android:screenOrientation="sensor" /> 

    <!-- android:windowSoftInputMode="stateVisible|adjustResize" --> 
    <activity 
     android:name=".BasicDataActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="sensor" > 
    </activity> 
    <activity 
     android:name=".AnalysisActivity" 
     android:configChanges="orientation|keyboardHidden|screenSize" 
     android:screenOrientation="sensor" /> 
    <activity 
     android:name=".authorization.AuthenticatorActivity" 
     android:configChanges="orientation|keyboardHidden|screenSize" 
     android:label="@string/account_register" 
     android:screenOrientation="sensor" /> 
    <activity 
     android:name=".authorization.LocalAuthenticatorActivity" 
     android:label="@string/account_register" 
     android:screenOrientation="sensor" /> 
    <activity 
     android:name=".authorization.SingUpActivity" 
     android:label="@string/account_register" 
     android:screenOrientation="sensor" /> 

    <service android:name=".authorization.TronPosAuthenticatorService" > 
     <intent-filter> 
      <action android:name="android.accounts.AccountAuthenticator" /> 
     </intent-filter> 

     <meta-data 
      android:name="android.accounts.AccountAuthenticator" 
      android:resource="@xml/authenticator" /> 
    </service> 
    <activity 
     android:name=".CountryPicker" 
     android:label="@string/app_name" 
     android:noHistory="true" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".UnitActivity" 
     android:label="@string/title_activity_unit" > 
    </activity> 
</application> 

+1

顯示您的清單 – 2015-03-31 07:24:49

+0

此外,除了可以發佈您的完整的AndroidManifest.xml,做一個'亞行卸載-d com.yourpackage.yourapp'刪除從應用程序您的設備,並確保您使用的是最新版本 – 2015-03-31 07:26:12

+0

@piyushkukadiya清單增加 – 2015-03-31 07:58:57

回答

0

確保只有活動的一箇中有

<intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 

,或者你會混淆系統和Android這個標籤將在菜單中製作兩個不同的圖標啓動器,

沒錯卸載從仿真器和設備,並重新安裝應用程序的所有組件

+0

只有一個活動有這個意圖,我已unintalled everyting並重新安裝。仍然是同樣的事情。 – 2015-03-31 07:53:14

+0

清理您的項目並重新構建它應該工作 – 2015-03-31 07:54:32

+0

清潔沒有幫助。如果有幫助,我用整個清單編輯我的問題。 – 2015-03-31 08:17:45