我在Activatedialog
注册>活动中使用此onPostExecute
方法,并且当警告对话框消失时需要启动login
活动..但是我试图这样做,但我得到错误。
public void Activatedialog(String jsonmsg, final String name)
{
final AlertDialog.Builder alert = new AlertDialog.Builder(ct);
alert.setTitle("Activate Account");
alert.setMessage(jsonmsg);
// Set an EditText view to get user input
final EditText input = new EditText(ct);
alert.setView(input);
alert.setCancelable(true);
Log.d("MYLOG","before +ve button click");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
String code = input.getText().toString();
Log.d("MYLOG","before try");
try{
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("u",name ));
params.add(new BasicNameValuePair("code",code ));
JSONObject json = jsonParser.makeHttpRequest(ACTIVATION_URL,"POST", params);
Log.d("MYLOG","after request for json");
stcode = json.getJSONObject("activate").getInt("statuscode");
stmsg = json.getJSONObject("activate").getString("statusmessage");
Log.d("MYLOG","after json parsing : json data is "+stmsg+"stcodeis "+stcode);
if(stcode == 1)
{
dialog.dismiss();
Log.d("MYLOG"," in check json data is "+stmsg+" stcodeis "+stcode);
Intent i = new ("LOGIN");startActivity(i);![i get this error][1]
Toast.makeText(ct, " "+stmsg, Toast.LENGTH_SHORT).show();
}
else if(stcode == 0)
{
Log.d("MYLOG"," in check json data is "+stmsg+" stcodeis "+stcode);
Toast.makeText(ct, " "+stmsg+" "+stcode, Toast.LENGTH_SHORT).show();
}
}
catch(JSONException e)
{
e.printStackTrace();
Toast.makeText(ct, ""+e, Toast.LENGTH_LONG).show();
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
// Canceled.
Toast.makeText(ct, "Your Account is not Activated.Login to Activate", Toast.LENGTH_LONG).show();
}
});
alert.show();
}
}
答案 0 :(得分:0)
要启动活动,意图必须具有以下参数。上下文和目标活动。让我们开始活动“Login.java”。
Intent i = new Intent(getApplicationContext(), Login.class);
startActivity(i);
答案 1 :(得分:0)
您可以这样做:
AlertDialogManager alert = new AlertDialogManager(StartActivity.this);
AlertDialogManager构造函数:
public void AlertDialogManager(final Context context) {
activity = (Activity) context;
}
你可以启动这样的活动:
Intent intent = new Intent(activity , Login.class);
activity.startActivity(intent);
答案 2 :(得分:0)
您错误地创建了意图。
1&GT;通过向项目添加新活动,添加您要打开的相关活动Login
。
2&gt;按以下方式创建意图
Intent intent = new Intent(getApplicationContext(), Login.class);
3&gt;使用创建的意图启动活动
startActivity(i);