Iam無法獲取接收器文件中元數據中指定的值,iam獲取空指針異常。使用getReceiverInfo時獲取空指針異常
在manifest文件中我已指定
<receiver android:name=".SmsReceiver" >
<intent-filter android:priority="10">
<action
android:name="android.provider.Telephony.SMS_RECEIVED"
android:enabled="true" />
<meta-data android:name="Algorithm" android:value="AES"/>
</intent-filter>
</receiver>
,並在reciever IAM指定
public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// ---get the SMS message passed in---
Bundle bundle = intent.getExtras();
ActivityInfo appi = null;
try {
appi = context.getPackageManager().getReceiverInfo(new ComponentName(context,"intgafaes.mobileafaes.androidafaes.securesms.ADDFriendSmsReceiver"), PackageManager.GET_META_DATA);
} catch (NameNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Bundle bundle1 = appi.metaData;
String value = bundle1.getString("Algorithm");
System.out.println("Value is "+value);
if(value.equals("AES"))
{
System.out.println("entered into onRecieve");
}
Iam正確獲取包名,但無法檢索元數據標籤中指定算法的值 – user1203673 2012-04-23 04:34:07