Reputation: 1
I'm currently running a project for recieving message but as I'm about to run my application it sends me a fatal exception & my app is forced closed with a message com.project.SMSresponder has stopped running.
log cat:
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 files:
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();
}
}
}
}
AND SECOND ONE:
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);
}
});
}
}
Upvotes: 0
Views: 609
Reputation: 132982
register your Recieve
BroadcastReciver and Stat.java
Activity in manifest as:
<receiver android:name=".Recieve" android:exported="true" >
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity
android:name=".Stat" />
<activity
android:name=".SMSresponderActivity" />
uses-permission in your manifest file:
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
EDIT :finally big error is that Recieve is not an activity it's broadcast receiver or you are starting it as Activity so Change it bez when any new sms is reciver your Recieve automatic fire up
public void onClick(View v)
{
// TODO Auto-generated method stub
//Intent intent = new Intent(Stat.this,Recieve.class);
Intent intent = new Intent(Stat.this,YOUR_NEXT_ACTIVITY.class); //you are passing Recieve here
startActivity(intent);
}
Upvotes: 1
Reputation: 6805
Caused by: java.lang.ClassNotFoundException: com.project.SMSresponderActivity
You are missing com.project.SMSresponderActivity
on the manifest.
<activity
android:name=".SMSresponderActivity"
android:label="@string/smsResponder_name" >
</activity>
You'll need to specify all activities in your manifest, as well as receivers. I'm seeing that you don't have them either (as stated by @imran khan).
Upvotes: 3