0
앱을 사용하여 마지막으로 알려진 위치를 확인하고 미리 정의 된 임계 값을 초과하는 경우 들어오는 SMS 알림을 표시하지 않고 보내는 사람. 내가 에뮬레이터 사이에이를 테스트 할 때패시브 SMS 수신기가 수신시 치명적인 오류가 발생합니다.
는 다음 logcats 실패 : 여기
11-28 09:07:03.747: E/AndroidRuntime(324): FATAL EXCEPTION: main
11-28 09:07:03.747: E/AndroidRuntime(324): java.lang.RuntimeException: Unable to instantiate receiver biz.midl.drivereply.SMSReceiver: java.lang.ClassNotFoundException: biz.midl.drivereply.SMSReceiver in loader dalvik.system.PathClassLoader[/data/app/biz.midl.drivereply-1.apk]
11-28 09:07:03.747: E/AndroidRuntime(324): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.app.ActivityThread.access$3200(ActivityThread.java:125)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.os.Handler.dispatchMessage(Handler.java:99)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.os.Looper.loop(Looper.java:123)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-28 09:07:03.747: E/AndroidRuntime(324): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 09:07:03.747: E/AndroidRuntime(324): at java.lang.reflect.Method.invoke(Method.java:521)
11-28 09:07:03.747: E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-28 09:07:03.747: E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-28 09:07:03.747: E/AndroidRuntime(324): at dalvik.system.NativeStart.main(Native Method)
11-28 09:07:03.747: E/AndroidRuntime(324): Caused by: java.lang.ClassNotFoundException: biz.midl.drivereply.SMSReceiver in loader dalvik.system.PathClassLoader[/data/app/biz.midl.drivereply-1.apk]
11-28 09:07:03.747: E/AndroidRuntime(324): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
11-28 09:07:03.747: E/AndroidRuntime(324): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
11-28 09:07:03.747: E/AndroidRuntime(324): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
11-28 09:07:03.747: E/AndroidRuntime(324): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
11-28 09:07:03.747: E/AndroidRuntime(324): ... 10 more
내 수신기 활동입니다 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="biz.midl.drivereply"
android:versionCode="1"
android:versionName="0.5" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="biz.midl.drivereply.PassiveLocationChangedReceiver"
android:enabled="true" />
<activity
android:name="biz.midl.drivereply.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="biz.midl.drivereply.Settings"
android:label="@string/title_activity_settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="biz.midl.drivereply.PassiveSms"
android:label="@string/title_activity_passive_sms" >
</activity>
<receiver android:name="biz.midl.drivereply.SMSReceiver" >
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service android:name="biz.midl.drivereply.MyService" >
<intent-filter>
<action android:name="com.example.MyService" />
</intent-filter>
</service>
<activity
android:name="biz.midl.drivereply.PassiveSMSSend"
android:label="@string/title_activity_passive_smssend" >
</activity>
</application>
</manifest>
: 또한
package biz.midl.drivereply;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
public class PassiveSms extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPref= context.getSharedPreferences("chaosdriver", Context.MODE_PRIVATE);
int speedLimit = sharedPref.getInt("speedLimit", 5);
String message = sharedPref.getString("message", "I'm sorry, but I am driving. I will text you when I am able!");
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
float currentSpeedms = lastKnownLocation.getSpeed();
float currentSpeedMPH = (float) (currentSpeedms * 2.237);
int newSpeed = (int) currentSpeedMPH;
if (newSpeed > speedLimit)
{
Bundle extras = intent.getExtras();
if (extras == null)
{
return;
}
abortBroadcast();
Object[] pdus = (Object[]) extras.get("pdus");
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[0]);
String origNumber = msg.getOriginatingAddress();
onSend(origNumber, message);
}
}
public void onSend(String px, String message)
{
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(px, null, message, null, null);
}
}
, 여기 내 매니페스트입니다
디버그를 실행했지만 수신기 단계/중단 점을 표시하지 않습니다.
무엇이 발생했는지에 대한 제안이 있으십니까?