Android应用程序安装,但不会在设备上打开 [英] Android Application Installed but won't open on device

查看:270
本文介绍了Android应用程序安装,但不会在设备上打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建Android上的应用程序。我正在开发它使用adt。

这是关于NFC。就目前而言,只读取和写入标签。

我测试我的移动设备上运行我的应用程序,它工作得很好。

所以它编译良好,运行良好在我的Xperia Z1的索尼,但是当我拔掉我的电话,并在其上​​安装的APK我有一个问题:

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

它运行良好,我的手机上,当我启动它从月食,但是当我想要我的手机从我的计算机上拔下运行它并不想公开。在安装过程中没有错误消息...

我激活开发模式,并允许安装来源不明等...

不要有人有线索?

下面是我的manifest.xml:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.example.mynfc
安卓版code =1
机器人:=的versionName1.0><用途-SDK
    安卓的minSdkVersion =14
    机器人:targetSdkVersion =18/>
<使用许可权的android:NAME =android.permission.NFC/><用途特征
机器人:名字=android.hardware.nfc
机器人:要求=真/>
<应用
    机器人:allowBackup =真
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>
    <活动
        机器人:名字=com.example.mynfc.MainActivity
        机器人:标签=@字符串/ APP_NAME>
        &所述;意图滤光器>
            <作用机器人:名字=android.nfc.action.NDEF_DISCOVERED/>
        <类机器人:名字=android.intent.category.DEFAULT/>
        <数据机器人:mime类型=text / plain的/>
            <作用机器人:名字=android.intent.action.MAIN/>
          <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>    < /活性GT;
<活动机器人:WriteATagActivityNAME = />< /用途>< /清单>


解决方案

您应该意图过滤器分为以下内容:

 <意向滤光器>
    <作用机器人:名字=android.nfc.action.NDEF_DISCOVERED/>
    <类机器人:名字=android.intent.category.DEFAULT/>
    <数据机器人:mime类型=text / plain的/>
&所述; /意图滤光器>
&所述;意图滤光器>
    <作用机器人:名字=android.intent.action.MAIN/>
    <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>

有关的意图过滤器来匹配,动作,类别和数据应该是正确的。当您通过图标来打开应用程序,它会发送与主要的行动和类别LAUNCHER一个意图。因为它不包含数据类型,因为该类别不匹配DEFAULT和行动不符合NDEF_DISCOVERED,Android的认为你的意图过滤器无法处理它。

I created an application on Android. I am developing it on eclipse with ADT.

It is about nfc. For the moment it only reads and writes tag.

I run my application on my mobile device for testing and it works well.

So it compiles well and runs well on my Xperia Z1 Sony, however when i unplug my phone and install the apk on it i have a problem :

The install runs well but then i have two choices "Terminated" or "Open". The open is not clickable... I go to settings->Application->installed and i see my app that is install. I can force stop clear cache but not open it... I can't understand why.

It runs well on my phone when i launch it from eclipse but when i want to run it on my phone unplugged from my computer it doesn't want to be open. No error message during installation...

I activate dev mode and allow installation from unknown sources ect...

Do someone have a clue ??

Here is my 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>

解决方案

You should separate the intent filters into the following:

<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>

For an intent filter to match, action, category and data should be correct. When you open the app via the icon, it will send a intent with MAIN action, and category LAUNCHER. Because it does not contain a data type, and because the category does not match DEFAULT and action does not match NDEF_DISCOVERED, Android thinks your intent filter can not handle it.

这篇关于Android应用程序安装,但不会在设备上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆