我已将我想要首先从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>
答案 0 :(得分:0)
确保只有一个活动中包含此标记
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
或者你会混淆系统,android会在菜单中制作两个不同的图标启动器,
然后从模拟器和设备中卸载所有组件并重新安装应用程序