App behaving differently on various device with gingerbread

Put your problem here if it does not fit any of the other categories.

App behaving differently on various device with gingerbread

Postby prashantdawar » Wed Apr 10, 2013 8:39 am

this app accepts incoming message and pass(get method) to a local webserver.

problem 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?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. <span style="font-weight: bold">ReceiveSMSActivity.java</span>
  3.  
  4.  
  5. package com.example.smsx;
  6.  
  7. import android.app.Activity;
  8. import android.content.Intent;
  9. import android.net.Uri;
  10. import android.os.Bundle;
  11. import android.telephony.gsm.SmsMessage;
  12. import android.view.View;
  13. import android.widget.Button;
  14. import android.widget.TextView;
  15. import android.widget.Toast;
  16.  
  17. public class ReceiveSMSActivity extends Activity{
  18.        
  19.         static TextView messageBox;
  20.         Button btnSendSMS;
  21.        
  22.     @Override
  23.     public void onCreate(Bundle savedInstanceState) {
  24.         super.onCreate(savedInstanceState);
  25.         setContentView(R.layout.main);
  26.         messageBox=(TextView)findViewById(R.id.messageBox);
  27.     }
  28.      
  29.    
  30.     public static void updateMessageBox(String msg)
  31.     {
  32.         messageBox.append(msg);
  33.       }
  34.  }
  35.  
  36.  
  37. <span style="font-weight: bold"><span style="text-decoration: underline">TextMessageReceiver.java</span></span>
  38.  
  39. package com.example.smsx;
  40.  
  41. import java.util.ArrayList;
  42. import java.util.List;
  43.  
  44. import org.apache.http.NameValuePair;
  45. import org.apache.http.message.BasicNameValuePair;
  46. import android.content.BroadcastReceiver;
  47. import android.content.Context;
  48. import android.content.Intent;
  49. import android.net.Uri;
  50. import android.os.Bundle;
  51. import android.telephony.SmsMessage;
  52. import android.widget.Toast;
  53.  
  54. public class TextMessageReceiver extends BroadcastReceiver{
  55.        
  56.         public void onReceive(Context context, Intent intent)
  57.                 {//abortBroadcast();
  58.                 Bundle bundle = intent.getExtras();
  59.                 Object[] messages=(Object[])bundle.get("pdus");
  60.                 SmsMessage[] sms=new SmsMessage[messages.length];
  61.                
  62.                 for(int n=0;n<messages.length;n++){
  63.                         sms[n]=SmsMessage.createFromPdu((byte[]) messages[n]);
  64.                 }
  65.                
  66.                 for(SmsMessage msg:sms){
  67.                         ReceiveSMSActivity.updateMessageBox("\nFrom: "+msg.getOriginatingAddress()+"\n"+
  68.                                         "Message: "+msg.getMessageBody()+"\n");
  69.                        
  70.          
  71.                 // Building post parameters
  72.                 // key and value pair
  73.                 List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
  74.                 nameValuePair.add(new BasicNameValuePair("phoneNo", msg.getOriginatingAddress()));
  75.                 nameValuePair.add(new BasicNameValuePair("message",msg.getMessageBody()));
  76.          
  77.                 // Url Encoding the POST parameters
  78.                 String url = "http://10.14.1.154/smsToDb.php?phoneNo="+msg.getOriginatingAddress()
  79.                                         +"&message="+msg.getMessageBody();
  80.                         Toast.makeText(context, url, Toast.LENGTH_SHORT).show();
  81.  HttpGet myGet = new HttpGet(url);// app crashes with this line and request is also not made. try catch does not work
  82.                          Intent i = new Intent(Intent.ACTION_VIEW);
  83.                             i.setData(Uri.parse(url));
  84.                             i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  85.                             context.startActivity(i);
  86.                
  87.                 }
  88.                 }
  89.         }
  90.  
  91.  
Parsed in 0.043 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. sms manifest .xml
  3.  
  4. <?xml version="1.0" encoding="utf-8"?>
  5. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  6.    package="com.example.smsx"
  7.    android:versionCode="1"
  8.    android:versionName="1.0" >
  9.  
  10.     <uses-sdk
  11.        android:minSdkVersion="8"
  12.        android:targetSdkVersion="8" />
  13.     <uses-permission android:name="android.permission.RECEIVE_SMS" />
  14.     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  15.    
  16.  
  17.     <application
  18.        android:allowBackup="true"
  19.        android:icon="@drawable/ic_launcher"
  20.        android:label="@string/app_name"
  21.        android:theme="@style/AppTheme" >
  22.         <activity
  23.            android:name="com.example.smsx.ReceiveSMSActivity"
  24.            android:label="@string/app_name" >
  25.             <intent-filter>
  26.                 <action android:name="android.intent.action.MAIN" />
  27.                 <category android:name="android.intent.category.LAUNCHER" />
  28.             </intent-filter>
  29.         </activity>
  30.         <receiver android:name="com.example.smsx.TextMessageReceiver" android:exported="true" >
  31.                         <intent-filter android:priority="1000">
  32.                 <action android:name="android.provider.Telephony.SMS_RECEIVED" />
  33.                         </intent-filter>
  34.                 </receiver>
  35.     </application>
  36.  
  37. </manifest>
  38.  
  39.  
  40.  
  41.  
  42. main.xml
  43.  
  44.  
  45. <?xml version="1.0" encoding="utf-8"?>
  46. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  47.    android:orientation="vertical"
  48.    android:layout_width="fill_parent"
  49.    android:layout_height="fill_parent"
  50.    >
  51.     <TextView
  52.         android:id="@+id/messageBox"
  53.         android:text="message will appear here"
  54.         android:layout_width="fill_parent"
  55.    android:layout_height="wrap_content"
  56.   />  
  57. </LinearLayout>
  58.  
  59.  
Parsed in 0.006 seconds, using GeSHi 1.0.8.4
prashantdawar
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Apr 10, 2013 7:56 am

Top

Re: App behaving differently on various device with gingerb

Postby jodimello » Wed Apr 10, 2013 2:12 pm

Simulators only get you so far. You could have your app tested or even get some help with the development itself. You may want to procure the services of an android app development company.
jodimello
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Apr 10, 2013 2:07 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests