我是第一次在外接手机上测试我的应用程序......它在模拟器上运行得很好。我的外部设备是三星Galaxy S6 Edge。
我无法弄清楚错误的位置,因为当我在调试模式下运行它并在启动活动的onCreate()的第一行放置一个断点时,它会在它到达之前抛出错误。 / p>
虽然解决方案很棒,但我真的很想知道我需要采取的步骤来找到解决问题的根本原因并解决问题。
由于
Launching application: com.projects.fbgrecojr.vamoose/com.projects.fbgrecojr.vamoose.LoginActivity.
DEVICE SHELL COMMAND: am start -n "com.projects.fbgrecojr.vamoose/com.projects.fbgrecojr.vamoose.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.projects.fbgrecojr.vamoose/.LoginActivity }
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.projects.fbgrecojr.vamoose/.LoginActivity } from null (pid=31173, uid=2000) not exported from uid 10224
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:2586)
at com.android.commands.am.Am.runStart(Am.java:768)
at com.android.commands.am.Am.onRun(Am.java:307)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:102)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:255)
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.projects.fbgrecojr.vamoose" >
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_main" >
</activity>
<activity
android:name=".UserActivity"
android:label="@string/title_activity_user" >
</activity>
<activity
android:name=".AdminActivity"
android:label="@string/title_activity_admin" >
</activity>
<activity
android:name=".AdminSettings"
android:label="@string/title_activity_admin_settings" >
</activity>
<activity
android:name=".ContactsActivity"
android:label="@string/title_activity_contacts" >
</activity>
<activity
android:name=".AddUser"
android:label="@string/title_activity_specific_contact" >
</activity>
<activity
android:name=".User"
android:label="@string/title_activity_user" >
</activity>
<activity
android:name=".HistoryActivity"
android:label="@string/title_activity_history" >
</activity>
<activity
android:name=".CalendarActivity"
android:label="@string/title_activity_calendar" >
</activity>
<activity
android:name=".AboutActivity"
android:label="@string/title_activity_about" >
</activity>
</application>
</manifest>
答案 0 :(得分:2)
在您的清单中,您应使用intent-filter
指定应在启动时启动的活动:
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这里的问题是,如果没有intent-filter
,默认情况下的活动不会被导出(docs on android:exported),并且只能由相同应用程序的组件或具有相同用户ID的应用程序启动。