現在、メッセージを受信するプロジェクトを実行していますが、アプリケーションを実行しようとすると致命的な例外が送信され、com.project.SMSresponder has stopped running というメッセージが表示されてアプリが強制的に閉じられます。
丸太の猫:
06-21 11:57:24.188: D/AndroidRuntime(335): Shutting down VM
06-21 11:57:24.188: W/dalvikvm(335): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-21 11:57:24.208: E/AndroidRuntime(335): FATAL EXCEPTION: main
06-21 11:57:24.208: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.project.smsresponder/com.project.SMSresponderActivity}: java.lang.ClassNotFoundException: com.project.SMSresponderActivity in loader dalvik.system.PathClassLoader[/data/app/com.project.smsresponder-1.apk]
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:507)
06-21 11:57:24.208: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-21 11:57:24.208: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-21 11:57:24.208: E/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
06-21 11:57:24.208: E/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.project.SMSresponderActivity in loader dalvik.system.PathClassLoader[/data/app/com.project.smsresponder-1.apk]
06-21 11:57:24.208: E/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-21 11:57:24.208: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-21 11:57:24.208: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
06-21 11:57:24.208: E/AndroidRuntime(335): ... 11 more
06-21 11:57:34.199: I/Process(335): Sending signal. PID: 335 SIG: 9
Maniseft.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mydroidX.first"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Starting_point"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Java ファイル:
public class Recieve extends BroadcastReceiver
{
String lsms;
/* package */ static final String ACTION =
"android.provider.Telephony.SMS_RECEIVED";
private static final String TAG = "SMSBroadcastReceiver";
private static final int MAX_SMS_MESSAGE_LENGTH = 0;
@Override
public void onReceive(Context context, Intent intent) {
//---get the SMS message passed in---
Log.i(TAG, "Intent recieved: " + intent.getAction());
if (intent.getAction().equals(ACTION)) {
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null) {
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += "SMS from " + msgs[i].getOriginatingAddress();
str += " :";
str += msgs[i].getMessageBody().toString();
str += "\n";
}
//---display the new SMS message---
Toast.makeText(context, str,
Toast.LENGTH_SHORT).show();
}
}
}
}
そして2つ目:
public class Stat extends Activity{
Button btstat;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.rtlayout);
btstat = (Button) findViewById(R.id.button1);
btstat.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent = new Intent(Stat.this,Recieve.class);
startActivity(intent);
}
});
}
}