我已經將我想要首先從MainActivity運行的活動更改爲另一個活動。Android啓動啓動錯誤的活動
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
我的清單現在看起來是這樣的:我通過編輯Android清單動人這段代碼這樣做
<?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>
當我在我的手機和平板電腦(上運行從android工作室)我得到下面的錯誤和應用doesent像以前一樣自動啓動。但是,當我點擊該圖標時,通常會首先啓動正確的活動。
但是,當我使用模擬器正確的活動只在第一次安裝時啓動,然後以前設置的活動。
我不知道爲什麼會發生這種情況。我完全卸載了應用程序並重新安裝,我清理了我的項目,重新構建了它,沒有任何東西似乎有所作爲,我在清單中找不到任何問題。有任何想法嗎?
和錯誤:
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)
刪除'機器人:noHistory = 「真」'在清單和嘗試。 – Psypher 2015-04-03 10:59:56
我不需要歷史記錄,因爲在我們通過它之後,不應該通過後退按鈕訪問此活動。 – 2015-04-03 11:10:13
@ranjith我試過沒有歷史,只是爲了確保結果是一樣的。 – 2015-04-03 12:22:44