Saturday, 31 August 2013

app redirect to another activity in android

app redirect to another activity in android

This is my notification generate functionality in android application.
public class MyDealProducts extends ListActivity {
MyDealProductsAdapter mydealproductsAdapter;
AlertDialog.Builder alertDialog;
JSONParser jParser = new JSONParser();
public static int success;
ArrayList<HashMap<String, String>> mydealsList;
private static String url_all_products =
"http://192.168.2.102/android_connect/get_my_deal_products.php";
ListView mydeal_products;
AlertDialogManager alert = new AlertDialogManager();
ConnectionDetector cd;
JSONObject json;
public static String product_id;
private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCTS = "products";
private static final String TAG_PID = "customer_id";
public static final String TAG_ID = "product_id";
JSONArray products = null;
public static final int DIALOG_LOADING = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mydealproducts);
my_deals = (TextView) findViewById(R.id.my_deals);
my_deals.setBackgroundResource(R.drawable.headerradius);
l_my_deals = (TextView) findViewById(R.id.l_my_deals);
l_my_deals.setBackgroundResource(R.drawable.headerradius);
new MyDeals().execute();
mydeal_products = getListView();
}
class MyDeals extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_LOADING);
}
protected String doInBackground(String... args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("customer_id",
Constants.response));
json = jParser.makeHttpRequest(url_all_products, "GET", params);
Log.d("All Products: ", json.toString());
try {
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
products = json.getJSONArray(TAG_PRODUCTS);
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
String customer_id = c.getString(TAG_PID);
String product_id = c.getString(TAG_ID);
HashMap<String, String> map = new HashMap<String,
String>();
map.put(TAG_PID, customer_id);
map.put(TAG_NAME, product_name);
mydealsList.add(map);
}
} else {
}
} catch (JSONException e) {
e.printStackTrace();
}
return json.toString();
}
protected void onPostExecute(String file_url) {
super.onPostExecute(file_url);
dismissDialog(DIALOG_LOADING);
if (success == 1) {
runOnUiThread(new Runnable() {
public void run() {
mydealproductsAdapter = new
MyDealProductsAdapter(MyDealProducts.this, mydealsList);
mydeal_products.setAdapter(mydealproductsAdapter);
}
});
}
else
{
AlertDialog alertDialog = new AlertDialog.Builder(
MyDealProducts.this).create();
alertDialog.setMessage("No offer is given to any dealing products");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alertDialog.show();
}
}
}
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_LOADING:
final Dialog dialog = new Dialog(this,
android.R.style.Theme_Translucent);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_progress_dialog);
dialog.setCancelable(true);
return dialog;
default:
return null;
}
};
}
i have run the application means its stay 2 sec on these MyDealProducts
page.after that its automatically redirect to another class. Why i have
facing these issue ??? please give a solution for these ???

No comments:

Post a Comment