朋友我正在使用意图从一个活动导航到另一个活动。导航过程如何花费大约一分钟。请查找日志
08-21 18:01:32.719: I/System.out(4636): Button has been clicked
08-21 18:02:32.999: I/System.out(4636): successfull navigation
代码:
public void onClick(View v) {
if(v==refreshButton)
{
System.out.println("Button has been clicked");
startActivity(new Intent(this,Refresh.class));
}
请同样帮助我。我试过清理项目并重新启动了智能手机。
刷新课程
public class RefreshSettings extends Activity implements android.view.View.OnClickListener
{
Button refresh;
EditText code;
String pinCode;
TelephonyManager telephonyManager;
String imei;
@Override
protected void onSaveInstanceState(Bundle outState) {
System.out.println("successfull navigation");
super.onSaveInstanceState(outState);
setContentView(R.layout.refresh_settings);
telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
imei=telephonyManager.getDeviceId();
refresh=(Button)findViewById(R.id.button_Refresh_Settings);
refresh.setOnClickListener(this);
code=(EditText)findViewById(R.id.edittext_Refresh_Code);
}
}
答案 0 :(得分:1)
将onSaveInstanceState()
更改为onCreate()
。
从文档中我了解到应该调用onSaveInstanceState()来仅存储临时信息,
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
System.out.println("successfull navigation");
setContentView(R.layout.refresh_settings);
telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
imei=telephonyManager.getDeviceId();
refresh=(Button)findViewById(R.id.button_Refresh_Settings);
refresh.setOnClickListener(this);
code=(EditText)findViewById(R.id.edittext_Refresh_Code);
}