I should call a method from a activity to another activity. my firstclass is:
public class firstclass extends Activity {
public String Kind(){
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean Key = preferences.getBoolean("Key", true);
if(Key){
name="you";
}
else{
name="me";
}
return name;
}
}
secondclass is:
public class secondclass extends Activity {
public void take(String token, int transactionId) {
firstclass first = new firstclass(); //error in this class
first.Kind();
}
}
My error is:
03-25 19:05:39.082 5421-5487/com.example.com E/AndroidRuntime﹕ FATAL EXCEPTION: pool-5-thread-1
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:197)
at android.os.Handler.<init>(Handler.java:111)
at android.app.Activity.<init>(Activity.java:759)
at com.example.com.firstclass<init>(firstclass.java:17)
at com.example.com.secondclass(secondclass.java:157)