[b]problem[/b][u][/u] is app is running file in avd gingerbread
but when i run it in motorola xt311 gingerbread it runs and accept message but when passing url intent to start web browser to android system browser just starts google.com
and app runs but do not even accept messages in samsung galaxy y running same gingerbread
my effort :
1. on samsung this may be the priority issue but i choose the highest priority for my app?
2. app crashes without flag on intent?
3. app doesnot work with httpget or httppost,why?
4. app works fully on avd , partially on motorola and only start activity RecieveSmsActivity on samsung galaxy and works no more ,not even recieve sms?
ReceiveSMSActivity.java
package com.example.smsx;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class ReceiveSMSActivity extends Activity{
static TextView messageBox;
Button btnSendSMS;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
messageBox=(TextView)findViewById(R.id.messageBox);
}
public static void updateMessageBox(String msg)
{
messageBox.append(msg);
}
}
TextMessageReceiver.java
package com.example.smsx;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class TextMessageReceiver extends BroadcastReceiver{
public void onReceive(Context context, Intent intent)
{//abortBroadcast();
Bundle bundle = intent.getExtras();
Object[] messages=(Object[])bundle.get("pdus");
SmsMessage[] sms=new SmsMessage[messages.length];
for(int n=0;n<messages.length;n++){
sms[n]=SmsMessage.createFromPdu((byte[]) messages[n]);
}
for(SmsMessage msg:sms){
ReceiveSMSActivity.updateMessageBox("\nFrom: "+msg.getOriginatingAddress()+"\n"+
"Message: "+msg.getMessageBody()+"\n");
// Building post parameters
// key and value pair
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("phoneNo", msg.getOriginatingAddress()));
nameValuePair.add(new BasicNameValuePair("message",msg.getMessageBody()));
// Url Encoding the POST parameters
String url = "http://10.14.1.154/smsToDb.php?phoneNo="+msg.getOriginatingAddress()
+"&message="+msg.getMessageBody();
Toast.makeText(context, url, Toast.LENGTH_SHORT).show();
HttpGet myGet = new HttpGet(url);// app crashes with this line and request is also not made. try catch does not work
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
sms manifest .xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smsx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.smsx.ReceiveSMSActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.smsx.TextMessageReceiver" android:exported="true" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/messageBox"
android:text="message will appear here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment