I am having issues getting this to work, here is what I am trying to get to: an onClickListener that will get the state of the radio and return a toast. But I am messing up somewhere. I am having an issue with the intent, anyone able to shed some light on this?the intent is not able to be resolved. (Yes, I obviously have imported it.) Here is what I have:
public class MainActivity extends Activity {
protected Intent intent;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button check = (Button)findViewById(R.id.Button01);
check.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v){
getIntent();
int state= intent.getIntExtra(TelephonyManager.EXTRA_STATE, -1);
String msg=null;
switch (state) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
break;
}
}
});
}
}
You don’t store the value returned by getIntent(). This is better :