1

I need to run the following when i get a message from my GCM listner:

public void GetInfo1 (Bundle data){

    Log.d("Get Messages", "Data: " + String.valueOf(data));


    final String uid = data.getString("uid");
    final String infoid = data.getString("infoid");
    GetInfo(uid, infoid); // This is another activity that does a Json Post and returns a array that i use to populate my Listview
}

This is how i call the function :

if (activityName.equals(MyActivity.class.getName())) {
           // Execute that special method from ActivityListView
           Log.d(TAG, "Activity is running");
           MyActivity myActivity = new MyActivity();
           myActivity.Getinfo1(data);
       } else {
           // Show the notification
           sendNotification(message);
       }

but i am always getting this error :

Can't create handler inside thread that has not called Looper.prepare()

I have tried everything, and am out of ideas now,

I need to call the function and pass the vars but if i make it static i get a error that you cant call non static methods from a static ....

Please any help will be fantastic

T-

Tanya Visagie
  • 41
  • 1
  • 2

1 Answers1

0

In general, to start a new activity, you should not instantiate the activity directly but rather use an Intent to trigger the activity, using either startActivity() or startActivityForResult(). However, in this case, it would appear that you are doing an operation that is intended to run in the background (without user interaction). Activity is an application component intended for direct interaction with the user. For background processing, you should be using a Android Service, instead. As with an Activity, you do not create services directly, but rather invoke them by firing off appropriate Intents.

Michael Aaron Safyan
  • 93,612
  • 16
  • 138
  • 200