I believe I have a simple question…. but for me as beginner, I can’t see it anymore.
In a class I want to get some var’s from another class.
class 1:
package com.blabla;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//get shared preferences
GetSettings test1 = new RingSettings();
String theSMStext = test1.getSMStext();
Boolean theActivateSMS = test1.getActivateSMS();
}
}
class 2:
package com.blabla;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
public class GetSettings {
/**
* @param args
*/
private String SMStext;
private Boolean ActivateSMS;
public static void RingSettings(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
String SMStext = sp.getString("SMStext", "0");
Boolean ActivateSMS = sp.getBoolean("ActivateSMS", false);
}
public String getSMStext(){
return SMStext;
}
public Boolean getActivateSMS(){
return ActivateSMS;
}
}
Eclipse is giving me in class1 “RingSettings can’t resolved to a type” => at GetSettings test1 = new RingSettings();
What I’m doing wrong?!
You definitly have a few things to fix here.
These are just a few to get started. I don’t mean to be rude here but you should be playing with some simpler examples to better learn the basics of Java. That being said, if you fix the above problems and repost your code someone should be able to get you closer to what your trying to accomplish.
Check out this info on the
newkeyword: (to get you started)The new operator instantiates a class by allocating memory for a new object and returning a reference to that memory. The new operator also invokes the object constructor.
Good luck