【问题标题】:Android Application Installed but won't open on deviceAndroid 应用程序已安装但无法在设备上打开
【发布时间】:2013-12-15 15:13:57
【问题描述】:

我在 Android 上创建了一个应用程序。我正在使用 ADT 在 eclipse 上开发它。

这是关于 nfc 的。目前它只读写标签。

我在移动设备上运行我的应用程序进行测试,它运行良好。

所以它在我的 Xperia Z1 Sony 上编译和运行良好,但是当我拔下手机并在其上安装 apk 时出现问题:

安装运行良好,但我有两个选择“终止”或“打开”。 打开是不可点击的...我去设置->应用程序->已安装,我看到我的应用程序正在安装。我可以强制停止清除缓存但不能打开它...我不明白为什么。

当我从 Eclipse 启动它时,它在我的手机上运行良好,但是当我想在从计算机上拔下的手机上运行它时,它不想打开。安装过程中没有错误信息...

我激活了开发模式并允许从未知来源等安装...

有人知道吗?

这是我的 manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mynfc"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.NFC" />

<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.mynfc.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain"/>
            <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>
<activity android:name=".WriteATagActivity"/>

</application>

</manifest>

【问题讨论】:

    标签: android eclipse apk adt nfc


    【解决方案1】:

    您应该将意图过滤器分为以下几部分:

    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain"/>
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    

    对于要匹配的意图过滤器,操作、类别和数据应该是正确的。当您通过图标打开应用程序时,它会发送一个带有 MAIN 操作和类别 LAUNCHER 的意图。因为它不包含数据类型,并且因为类别不匹配 DEFAULT 并且操作不匹配 NDEF_DISCOVERED,Android 认为你的意图过滤器无法处理它。

    【讨论】:

    • 谢谢你救了我!!多亏了你,我明白出了什么问题:)!
    猜你喜欢
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 2015-02-05
    • 2020-06-28
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多