App Works fine in Emu but won't run on my phone.

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

App Works fine in Emu but won't run on my phone.

Postby ElectrcNINJA » Fri Mar 25, 2011 3:03 am

Well, hello! I'm having a problem with My App running on my G1. It does exactly what it's supposed to do in a 2.2 and 2.3.3 emulators. On the phone it runs i know to at least line 29 where the Text box is changed to "doing stuff". It's supposed to download and deserialize JSON data(followed tut) then list the "name" in the List View.

I've been trying to get it run on the phone for a few days and I'm about to loose it. >.< I'm very new to developing Android Apps. Thanks to anyone who has any idea what I'm doing wrong.

Here's the code if you need it,
Code: Select all
public class esx extends Activity {
   
   ArrayList<entry> eList;
   ArrayAdapter<String> aa;
   
   ArrayList<String> mainStrings;
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        TextView tv = (TextView) findViewById(R.id.textView1);
        tv.setText("Doingstuff");
        eList = null;
        new doStuff().execute();
       
    }
   
    private class doStuff extends AsyncTask<Void,Void,Void>
    {
       TextView tv = (TextView) findViewById(R.id.textView1);
       ListView lv = (ListView) findViewById(R.id.listView1);
 

      @Override
      protected Void doInBackground(Void... arg0) {      
         
         try {
            eList = entry.deserializeArray(ResourceHelper.loadManySerialized("http://seihexa.net/phproot/rawr.php?format=JSON"));
         } catch (JSONException e) {
            
            tv.setText("Fetch Failed");
            e.printStackTrace();
         }
      
         return null;
      }
         
      @Override
      protected void onPostExecute(Void result) {
         if (eList != null)
         {
            ArrayList<String> str = new ArrayList<String>();
            for (entry et : eList) {
               str.add(et.objName);
            }
            if (str != null)
            {
               aa = new ArrayAdapter<String>(esx.this, android.R.layout.simple_list_item_1); 
               for (String s : str)
               {
                  aa.add(s);
               }
            }
            
            lv.setAdapter(aa);
            aa.notifyDataSetChanged();
         }
         super.onPostExecute(result);
      }
         
      
      
    }
}
User avatar
ElectrcNINJA
Freshman
Freshman
 
Posts: 3
Joined: Fri Mar 25, 2011 2:42 am

Top

Re: App Works fine in Emu but won't run on my phone.

Postby raj_J2ME » Fri Mar 25, 2011 7:39 am

Welcome to the Android Forums.. :)

Well it will be quite tedious to find the issue by just looking at the code, I will request you to provide the error/exception and any other details about the same which is/are occurring on the device.
What is happening correct and what is not?
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Re: App Works fine in Emu but won't run on my phone.

Postby ElectrcNINJA » Fri Mar 25, 2011 9:49 pm

thanks raj. The Emulator does what it's supposed to.
1) Loads JSON Array from a php script(that gets data from MYSQL DB).
2) De-serializes the array into "entry" objects that are held in a ArayList.
3) loops though the entry objects in the ArrayList getting their name strings adding the names to a ListAdapter.
4) The ListAdapter tells ListView that the data has changed and should refresh.

It seems that the phone does what it's supposed to do but the list view wont refresh.

Emu Logcat :
http://pastebin.com/Dz3CdAcA

G1 (Phone) Logcat:
http://pastebin.com/cYjk0nCY
User avatar
ElectrcNINJA
Freshman
Freshman
 
Posts: 3
Joined: Fri Mar 25, 2011 2:42 am

Re: App Works fine in Emu but won't run on my phone.

Postby ElectrcNINJA » Sun Mar 27, 2011 5:37 am

I hate bumping, but there's a new development... i switched my code up and i got an error on the phone where the Emu dident... The JSON Download Task was returning NULL. I tested my php script in browser and after awhile i got a "Data connectivity problem", "The Server has failed to communitacte try again later". My phone is connected to my home Wifi like the emualtor but my server wont seem to talk to my phone... I now think that this is more of a server connection issue. If anyone know's what's up feel free reply.
User avatar
ElectrcNINJA
Freshman
Freshman
 
Posts: 3
Joined: Fri Mar 25, 2011 2:42 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests