上安装和QUOT Android的错误信息;没有内容提供者发现和QUOT; [英] Android error message on install "no content provider found"

查看:127
本文介绍了上安装和QUOT Android的错误信息;没有内容提供者发现和QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个广播接收器,被要求进来的每一个短信。所有公布的code要做到这一点(我能找到),要么是去precated或没有按科技工作。

我的code未能在安装时,此消息在日志中(两次):

  10月6号至17日:15:59.316 396 413W¯¯ActivityManager:没有内容提供商找到许可撤销:文件:///data/local/tmp/locator.apk
10月六号至17号:15:59.316 396 413W¯¯ActivityManager:没有内容提供商找到许可撤销:文件:///data/local/tmp/locator.apk
 

我的清单文件看起来是这样的:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  包=为com.example
  安卓版code =1
  机器人:VERSIONNAME =1.0>
<使用-SDK安卓的minSdkVersion =7/>
<使用-权限的Andr​​oid:名称=android.permission.RECEIVE_SMS/>
<使用-权限的Andr​​oid:名称=android.permission.READ_SMS/>

<应用机器人:图标=@可绘制/ ic_launcher机器人:标签=@字符串/ APP_NAME>
    <接收机器人:SmsReceiverNAME =>
        <意向滤光器>
            <作用机器人:名称=android.provider.Telephony.SMS_RECEIVED/>
        &所述; /意图滤光器>
    < /接收器>
< /用途>
 

。将很高兴,如果有人能指出我在做什么错。我开始怀疑,有阅读传入手机简讯的API。

我的源$ C ​​$ C是这样的:

 包com.example;
进口android.content.BroadcastReceiver;
进口android.content.Context;
进口android.content.Intent;
进口android.os.Bundle;
进口android.telephony.gsm.SmsMessage;
进口android.util.Log;


公共类SmsReceiver扩展的BroadcastReceiver {
    私有静态最后弦乐SMS_RECEIVED =android.provider.Telephony.SMS_RECEIVED;
    私有静态最后字符串变量=定位器;

    @燮pressWarnings(德precation)
    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
        Log.i(TAG,意图:收到:+ intent.getAction());

        如果(intent.getAction()== SMS_RECEIVED){
            捆绑包= intent.getExtras();
            如果(捆绑!= NULL){
                [对象]的PDU =(对象[])bundle.get(的PDU);
                最后SmsMessage []消息=新SmsMessage [pdus.length]
                的for(int i = 0; I< pdus.length;我++){
                    消息[I] = SmsMessage.createFromPdu((字节[])的PDU [I]);
                }
                如果(messages.length> -1){
                    Log.i(TAG,
                            消息:收到:+消息[0] .getMessageBody());
                }
            }
        }
    }
}
 

解决方案

您code(和我)只是正常的另一手机,马克。我曾闪过ICS到这款手机,我怀疑有一些稍微的失衡。这是手机还是构建。谢谢你,彼得

I'm trying to write a broadcast receiver that gets called for every SMS text message that comes in. All the published code to do that (that I can find) either has been deprecated or doesn't work.

My code fails at install time, with this message in the log (twice):

06-17 10:15:59.316   396   413 W ActivityManager: No content provider found for permission revoke: file:///data/local/tmp/locator.apk
06-17 10:15:59.316   396   413 W ActivityManager: No content provider found for permission revoke: file:///data/local/tmp/locator.apk

My manifest file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>

<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
    <receiver android:name=".SmsReceiver" > 
        <intent-filter> 
            <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
        </intent-filter> 
    </receiver>  
</application>

Would be glad if anyone could point out what I'm doing wrong. I'm beginning to suspect that there is no API for reading incoming SMSs.

My source code looks like this:

package com.example;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import android.util.Log;


public class SmsReceiver extends BroadcastReceiver {
    private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
    private static final String TAG = "locator";

    @SuppressWarnings("deprecation")
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "Intent recieved: " + intent.getAction());

        if (intent.getAction() == SMS_RECEIVED) {
            Bundle bundle = intent.getExtras();
            if (bundle != null) {
                Object[] pdus = (Object[]) bundle.get("pdus");
                final SmsMessage[] messages = new SmsMessage[pdus.length];
                for (int i = 0; i < pdus.length; i++) {
                    messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                }
                if (messages.length > -1) {
                    Log.i(TAG,
                            "Message recieved: " + messages[0].getMessageBody());
                }
            }
        }
    }
}

解决方案

Your code (and mine) works just fine on another handset, Mark. I had flashed ICS onto this phone, and I suspect there's something slightly out of whack. It's the handset or the build. Thank you, Peter

这篇关于上安装和QUOT Android的错误信息;没有内容提供者发现和QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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