Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TOP

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.

Prototype

int FLAG_ACTIVITY_CLEAR_TOP

To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.

Click Source Link

Document

If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

Usage

From source file:org.wso2.iot.agent.services.operation.OperationManager.java

/**
 * Configure device VPN profile.//from w  ww.j  a v  a 2s. co  m
 *
 * @param operation - Operation object.
 */
public void configureVPN(org.wso2.iot.agent.beans.Operation operation) throws AndroidAgentException {
    String serverAddress = null;
    JSONObject result = new JSONObject();

    try {
        JSONObject vpnData = new JSONObject(operation.getPayLoad().toString());
        if (!vpnData.isNull(resources.getString(R.string.intent_extra_server))) {
            serverAddress = (String) vpnData.get(resources.getString(R.string.intent_extra_server));
        }

    } catch (JSONException e) {
        operation.setStatus(resources.getString(R.string.operation_value_error));
        operation.setOperationResponse("Error in parsing VPN payload.");
        resultBuilder.build(operation);
        throw new AndroidAgentException("Invalid JSON format.", e);
    }

    if (serverAddress != null) {
        Intent intent = new Intent(context, AlertActivity.class);
        intent.putExtra(resources.getString(R.string.intent_extra_message_text),
                resources.getString(R.string.toast_message_vpn));
        intent.putExtra(resources.getString(R.string.intent_extra_operation_id), operation.getId());
        intent.putExtra(resources.getString(R.string.intent_extra_payload), operation.getPayLoad().toString());
        intent.putExtra(resources.getString(R.string.intent_extra_type), Constants.Operation.VPN);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        context.startActivity(intent);
    }

    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "VPN configured");
    }
    operation.setStatus(resources.getString(R.string.operation_value_completed));
    operation.setPayLoad(result.toString());
    resultBuilder.build(operation);
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

@Override
public void onResume() {
    //if exiting from the scan screen with an unregistered app
    if (GTConstants.exitingScanScreen && !Utility.deviceRegistered())
        onBackPressed();//w  ww  .j  a v a 2  s  . co  m

    //if this is a newly registered app then reboot
    if (newRegistration && Utility.deviceRegistered()) {
        try {
            Intent restartIntent = getPackageManager().getLaunchIntentForPackage(getPackageName());
            PendingIntent intent = PendingIntent.getActivity(HomeScreen.this, 0, restartIntent,
                    Intent.FLAG_ACTIVITY_CLEAR_TOP);
            AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
            manager.set(AlarmManager.RTC, System.currentTimeMillis() + 500, intent);
            System.exit(2);
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), "ON RESUME ERROR: " + e, Toast.LENGTH_LONG).show();
        }
    } else {
        if (!ScreenReceiver.wasScreenOn) {
            //Toast.makeText(getApplicationContext(), "ON RESUME", Toast.LENGTH_LONG).show();
            //if(ftpDownload.getStatus() != AsyncTask.Status.RUNNING)syncFTP();
            //syncFTP();
        }

        syncFTP();

        setuserBanner();

        //if returning from tag scan for time and attendance after an end shift then taa was set to 1
        //set taa to 2 and then launch dialog to display the time and attendance record and then signature page
        if (taa == 1) {
            taa = 0;
        }

        if (taa == 2) {
            //write to tar, transfer file to send directory
            Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName,
                    "End shift;" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true);

            //write additional info to tar file
            Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName,
                    "Total Time;" + Utility.gettimeDiff(Utility.getsessionStart(), Utility.getLocalDateTime())
                            + "\r\n" + "Time on Lunch;" + lunchTime + "\r\n" + "Time on Break;" + breakTime
                            + "\r\n",
                    true);

            //give time for file write
            Utility.initializeGeneralTimer(2000);
            do {
                Utility.Sleep(100);
            } while (!Utility.fileAccessComplete() && !Utility.getgeneraltimerFlag());

            lunchTime = "00:00:00:00";
            breakTime = "00:00:00:00";

            taa = 5;
            show_taaSignature_dialog(); //returning from end shift location scan
        }

        if (taa == 3) {
            //write the event 25 information to the file
            String GM = "";
            if (GTConstants.isSignature) {
                GM = Utility.getHeaderMessage("$GM") + ",25," + getCellID() + CRLF + "***SIGNATURE***" + CRLF
                        + Utility.getsharedPreference(HomeScreen.this, "signaturefileName");
                GTConstants.isSignature = false;
                signaturefileName = "";
            } else
                GM = Utility.getHeaderMessage("$GM") + ",25," + getCellID();

            Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName,
                    GM + "\r\n", true);

            //give time for file write
            Utility.initializeGeneralTimer(2000);
            do {
                Utility.Sleep(100);
            } while (!Utility.fileAccessComplete() && !Utility.getgeneraltimerFlag());

            //move the tar file to the send file folder 
            File from = new File(GTConstants.dardestinationFolder, GTConstants.tarfileName);

            //change the file name to match the $GM time and date
            String[] parse = GM.split(",");
            String newFile = GTConstants.LICENSE_ID.substring(7) + "_" + parse[10] + "_" + parse[2]
                    + "_tar.tar";

            File to = new File(GTConstants.sendfileFolder, newFile);
            from.renameTo(to);

            endshiftCode();

            taa = 0;
        }

        //check if the tag is in a tour
        if (GTConstants.exitingScanScreen) {
            if (GTConstants.isTour) {
                if (GTConstants.tourName.length() == 1) {
                    if (getlasttagScanned().length() == 16)
                        show_tours_dialog(true);
                } else {
                    updateTour(getlasttagScanned());
                }
            }

            //check if this is an account setup tag, designated by an "@&" as the first two characters
            if (getlasttagScanned().length() == 16) {
                String temp = Utility.get_from_GTParamsDataBase(HomeScreen.this, getlasttagScanned());
                if (temp.contains("@&")) {
                    temp = temp.substring(2);
                    setupAccounts("0", temp);
                    //Toast.makeText(getApplicationContext(), temp, Toast.LENGTH_LONG).show();
                }
            }

            GTConstants.exitingScanScreen = false;
        }

    }

    super.onResume();
}

From source file:org.wso2.emm.agent.services.operation.OperationManager.java

/**
 * Configure device VPN profile.//from ww w  .  ja  va2  s.c om
 *
 * @param operation - Operation object.
 */
public void configureVPN(org.wso2.emm.agent.beans.Operation operation) throws AndroidAgentException {
    String serverAddress = null;
    JSONObject result = new JSONObject();

    try {
        JSONObject vpnData = new JSONObject(operation.getPayLoad().toString());
        if (!vpnData.isNull(resources.getString(R.string.intent_extra_server))) {
            serverAddress = (String) vpnData.get(resources.getString(R.string.intent_extra_server));
        }

    } catch (JSONException e) {
        operation.setStatus(resources.getString(R.string.operation_value_error));
        operation.setOperationResponse("Error in parsing VPN payload.");
        resultBuilder.build(operation);
        throw new AndroidAgentException("Invalid JSON format.", e);
    }

    if (serverAddress != null) {
        Intent intent = new Intent(context, AlertActivity.class);
        intent.putExtra(resources.getString(R.string.intent_extra_message_text),
                resources.getString(R.string.toast_message_vpn));
        intent.putExtra(resources.getString(R.string.intent_extra_operation_id), operation.getId());
        intent.putExtra(resources.getString(R.string.intent_extra_payload), operation.getPayLoad().toString());
        intent.putExtra(resources.getString(R.string.intent_extra_type), Constants.Operation.VPN);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        context.startActivity(intent);
    }

    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "VPN configured");
    }
    operation.setStatus(resources.getString(R.string.operation_value_completed));
    operation.setPayLoad(result.toString());
    resultBuilder.build(operation);
}

From source file:com.canappi.connector.yp.yhere.BakeryView.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;//from  w  ww .j  a v  a  2  s  . c o  m
    switch (item.getItemId()) {

    case R.layout.searchview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, SearchView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.restaurantview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, RestaurantView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.groceryview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GroceryView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.gasstationview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GasStationView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.theaterview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, TheaterView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.couponview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, CouponView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.lubeview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, LubeView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.gameview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GameView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.bakeryview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, BakeryView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.repairview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, RepairView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.homeview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, HomeView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.settingsview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, SettingsView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

static void activateTab(Activity a, int id) {
    Intent intent = new Intent(Intent.ACTION_PICK);
    switch (id) {
    case R.id.artisttab:
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/artistalbum");
        break;//w ww. ja v a 2  s .com
    case R.id.albumtab:
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album");
        break;
    case R.id.songtab:
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        break;
    case R.id.playlisttab:
        intent.setDataAndType(Uri.EMPTY, MediaStore.Audio.Playlists.CONTENT_TYPE);
        break;
    case R.id.nowplaying:
        //   intent = new Intent(a, MediaPlaybackActivity.class);
        //   a.startActivity(intent);
        // fall through and return
    default:
        return;
    }
    intent.putExtra("withtabs", true);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    a.startActivity(intent);
    a.finish();
    a.overridePendingTransition(0, 0);
}

From source file:com.example.carsharing.LongWayActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent returnp = new Intent(LongWayActivity.this, PersonalCenterActivity.class);
        returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(returnp);/*from  ww w . j  a v  a  2  s  .  c  o  m*/
        return false;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.example.carsharing.CommuteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    photouri = Uri//  w w  w. j  a v  a  2 s. c  o  m
            .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_commute);

    activity_drawer = new Drawer(this, R.id.commute_layout);
    mDrawerToggle = activity_drawer.newdrawer();
    mDrawerLayout = activity_drawer.setDrawerLayout();

    // 
    standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE);
    standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
    primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE);

    drawername = (TextView) findViewById(R.id.drawer_name);
    drawernum = (TextView) findViewById(R.id.drawer_phone);
    queue = Volley.newRequestQueue(this);
    exchange = (ImageView) findViewById(R.id.commute_exchange);
    exchange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String temp = startplace.getText().toString();
            if (!temp.equals("") && !endplace.getText().toString().equals("")) {
                startplace.setText(endplace.getText().toString());
                endplace.setText(temp);
                float a, b;
                a = startplace_longitude;
                b = startplace_latitude;
                startplace_longitude = destination_longitude;
                startplace_latitude = destination_latitude;
                destination_longitude = a;
                destination_latitude = b;

            }
        }
    });

    bdriver = true;
    bmon = true;
    btue = true;
    bwed = true;
    bthu = true;
    bfri = true;

    startdate = (Button) findViewById(R.id.commute_startdate);
    earlystarttime = (Button) findViewById(R.id.commute_earliest_start_time);
    enddate = (Button) findViewById(R.id.commute_enddate);
    latestarttime = (Button) findViewById(R.id.commute_latest_start_time);
    increase = (Button) findViewById(R.id.commute_increase);
    decrease = (Button) findViewById(R.id.commute_decrease);
    s1 = (TextView) findViewById(R.id.commute_count);
    drawericon = (ImageView) findViewById(R.id.drawer_icon);
    startplace = (Button) findViewById(R.id.commute_startplace);
    endplace = (Button) findViewById(R.id.commute_endplace);
    sure = (Button) findViewById(R.id.commute_sure);
    sure.setEnabled(false);

    carbrand = (EditText) findViewById(R.id.commute_CarBrand);
    model = (EditText) findViewById(R.id.commute_CarModel);
    color = (EditText) findViewById(R.id.commute_color);
    licensenum = (EditText) findViewById(R.id.commute_Num);

    licensenum.addTextChangedListener(numTextWatcher);
    carbrand.addTextChangedListener(detTextWatcher);
    color.addTextChangedListener(coTextWatcher);
    model.addTextChangedListener(moTextWatcher);

    final TextView content = (TextView) findViewById(R.id.commute_content);

    commute_group = (RadioGroup) findViewById(R.id.commute_radiobutton);
    mRadio1 = (RadioButton) findViewById(R.id.commute_radioButton1);
    mRadio2 = (RadioButton) findViewById(R.id.commute_radioButton2);// RadioGroup

    mon = (CheckBox) findViewById(R.id.commute_checkBox1);
    tue = (CheckBox) findViewById(R.id.commute_checkBox2);
    wed = (CheckBox) findViewById(R.id.commute_checkBox3);
    thu = (CheckBox) findViewById(R.id.commute_checkBox4);
    fri = (CheckBox) findViewById(R.id.commute_checkBox5);
    sat = (CheckBox) findViewById(R.id.commute_checkBox6);
    sun = (CheckBox) findViewById(R.id.commute_checkBox7);

    commute = findViewById(R.id.drawer_commute);
    shortway = findViewById(R.id.drawer_shortway);
    longway = findViewById(R.id.drawer_longway);
    setting = findViewById(R.id.drawer_setting);
    personalcenter = findViewById(R.id.drawer_personalcenter);
    taxi = findViewById(R.id.drawer_taxi);

    star1 = (ImageView) findViewById(R.id.cummute_star);
    star2 = (ImageView) findViewById(R.id.commute_star01);

    // 
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName),
            Context.MODE_PRIVATE);
    UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0");

    // judge the value of "pre_page"
    Bundle bundle = this.getIntent().getExtras();
    String PRE_PAGE = bundle.getString("pre_page");
    if (PRE_PAGE.compareTo("ReOrder") == 0) { // 
        startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname"));
        bstart = true;
        endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname"));
        bend = true;
        startplace_longitude = bundle.getFloat("stpx");
        Log.e("startplace_longitude", String.valueOf(startplace_longitude));
        startplace_latitude = bundle.getFloat("stpy");
        Log.e("startplace_latitude", String.valueOf(startplace_latitude));
        destination_longitude = bundle.getFloat("epx");
        Log.e("destination_longitude", String.valueOf(destination_longitude));
        destination_latitude = bundle.getFloat("epy");
        Log.e("destination_latitude", String.valueOf(destination_latitude));
        startdate.setText(bundle.getString("re_commute_startdate"));
        bstartdate = true;
        enddate.setText(bundle.getString("re_commute_enddate"));
        benddate = true;
        weekrepeat = bundle.getString("weekrepeat");
        earlystarttime.setText(bundle.getString("re_commute_starttime"));
        bearlystarttime = true;
        latestarttime.setText(bundle.getString("re_commute_endtime"));
        blatestarttime = true;

        // weekrepeatcheckbox
        int len = weekrepeat.length();
        for (int i = 0; i < len; i++) {
            if (weekrepeat.charAt(i) == '1') {
                mon.setChecked(true);
                bmon = true;
            }
            if (weekrepeat.charAt(i) == '2') {
                tue.setChecked(true);
                btue = true;
            }
            if (weekrepeat.charAt(i) == '3') {
                wed.setChecked(true);
                bwed = true;
            }
            if (weekrepeat.charAt(i) == '4') {
                thu.setChecked(true);
                bthu = true;
            }
            if (weekrepeat.charAt(i) == '5') {
                fri.setChecked(true);
                bfri = true;
            }
            if (weekrepeat.charAt(i) == '6') {
                sat.setChecked(true);
                bsat = true;
            }
            if (weekrepeat.charAt(i) == '7') {
                sun.setChecked(true);
                bsun = true;
            }
        }
        // end
    }
    // judge the value of "pre_page"

    // database
    db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1);
    db1 = db.getWritableDatabase();
    about = findViewById(R.id.drawer_respond);
    about.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent about = new Intent(CommuteActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });
    setting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent setting = new Intent(CommuteActivity.this, SettingActivity.class);
            startActivity(setting);
        }
    });

    // database end

    star1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bstart) {
                if (Pointisliked(StartPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName);
                    content.put(getString(R.string.dbstring_longitude), startplace_longitude);
                    content.put(getString(R.string.dbstring_latitude), startplace_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    star2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bend) {
                if (Pointisliked(EndPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName);
                    content.put(getString(R.string.dbstring_longitude), destination_longitude);
                    content.put(getString(R.string.dbstring_latitude), destination_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    taxi.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    personalcenter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent personalcenter = new Intent(CommuteActivity.this, PersonalCenterActivity.class);
            startActivity(personalcenter);
        }
    });

    shortway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent shortway = new Intent(CommuteActivity.this, ShortWayActivity.class);
            shortway.putExtra("pre_page", "Drawer");
            startActivity(shortway);
        }
    });

    longway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent longway = new Intent(CommuteActivity.this, MainActivity.class);
            startActivity(longway);
        }
    });

    commute.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));

        }
    });

    mon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bmon = true;
            } else {
                bmon = false;
            }
            confirm();
        }
    });
    tue.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                btue = true;
            } else {
                btue = false;
            }
            confirm();
        }
    });
    wed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bwed = true;
            } else {
                bwed = false;
            }
            confirm();
        }
    });
    thu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bthu = true;
            } else {
                bthu = false;
            }
            confirm();
        }
    });
    fri.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bfri = true;
            } else {
                bfri = false;
            }
            confirm();
        }
    });
    sat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsat = true;
            } else {
                bsat = false;
            }
            confirm();
        }
    });
    sun.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsun = true;
            } else {
                bsun = false;
            }
            confirm();
        }
    });

    commute_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup arg0, int checkedId) {
            // TODO Auto-generated method stub18
            // ID

            // """"textView
            if (checkedId == mRadio2.getId()) {

                bpassenager = true;
                bdriver = false;

                licensenum.setEnabled(false);
                carbrand.setEnabled(false);
                color.setEnabled(false);
                model.setEnabled(false);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatNeed));
                licensenum.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                carbrand.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                color.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                model.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                licensenum.setInputType(InputType.TYPE_NULL);
                carbrand.setInputType(InputType.TYPE_NULL);
                color.setInputType(InputType.TYPE_NULL);
                model.setInputType(InputType.TYPE_NULL);
            } else {

                bpassenager = false;
                bdriver = true;

                licensenum.setEnabled(true);
                carbrand.setEnabled(true);
                color.setEnabled(true);
                model.setEnabled(true);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return null;
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatOffer));
                licensenum.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                carbrand.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                color.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                model.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                // licensenum.setText("");
                // carbrand.setText("");
                // color.setText("");
                // model.setText("");
                licensenum.setInputType(InputType.TYPE_CLASS_TEXT);
                carbrand.setInputType(InputType.TYPE_CLASS_TEXT);
                color.setInputType(InputType.TYPE_CLASS_TEXT);
                model.setInputType(InputType.TYPE_CLASS_TEXT);

                // start!
                selectcarinfo(UserPhoneNumber);
                // end!
            }
            confirm();
        }

        private void selectcarinfo(final String phonenum) {
            // TODO Auto-generated method stub
            String carinfo_selectrequest_baseurl = getString(R.string.uri_base)
                    + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action);

            Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl);
            StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            // TODO Auto-generated method stub
                            Log.d("carinfo_select", response);
                            String jas_id = null;
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                JSONObject json = json1.getJSONObject("result");
                                jas_id = json.getString("id");

                                if (jas_id.compareTo("") != 0) { // 

                                    carinfochoosing_type = 2;
                                    carbrand.setText(json.getString("carBrand"));
                                    model.setText(json.getString("carModel"));
                                    licensenum.setText(json.getString("carNum"));
                                    color.setText(json.getString("carColor"));

                                } else {
                                    carinfochoosing_type = 1;
                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }, new Response.ErrorListener() {

                        @Override
                        public void onErrorResponse(VolleyError error) {
                            // TODO Auto-generated method stub
                            Log.e("carinfo_selectresult_result", error.getMessage(), error);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("phonenum", phonenum);
                    return params;
                }
            };

            queue.add(stringRequest);
        }

    });

    sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (commute_group.getCheckedRadioButtonId() == mRadio1.getId()) {
                supplycar = "y";
            } else
                supplycar = "n";

            // start!
            Context phonenumber = CommuteActivity.this;
            SharedPreferences filename = phonenumber
                    .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE);
            username = filename.getString("refreshfilename", "0");
            commute_request(username, startdate.getText().toString(), enddate.getText().toString(),
                    earlystarttime.getText().toString(), latestarttime.getText().toString());
            // end!

        }

        private void commute_request(final String commute_phonenum, final String commute_startdate,
                final String commute_enddate, final String commute_starttime, final String commute_endtime) {
            // TODO Auto-generated method stub

            weekrepeat = "";
            if (bmon)
                weekrepeat += "1";
            if (btue)
                weekrepeat += "2";
            if (bwed)
                weekrepeat += "3";
            if (bthu)
                weekrepeat += "4";
            if (bfri)
                weekrepeat += "5";
            if (bsat)
                weekrepeat += "6";
            if (bsun)
                weekrepeat += "7";

            // start
            try {
                test_date = primary_date.parse(commute_startdate);
                standard_commute_startdate = standard_date.format(test_date);
                test_date = primary_date.parse(commute_enddate);
                standard_commute_enddate = standard_date.format(test_date);
                test_date = primary_time.parse(commute_starttime);
                standard_commute_starttime = standard_time.format(test_date);
                test_date = primary_time.parse(commute_endtime);
                standard_commute_endtime = standard_time.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // end!

            String commute_baseurl = getString(R.string.uri_base) + getString(R.string.uri_CommuteRequest)
                    + getString(R.string.uri_addrequest_action);
            // + "phonenum=" + commute_phonenum + "&startplacex=" +
            // String.valueOf(startplace_longitude) +
            // "&startplacey=" + String.valueOf(startplace_latitude) +
            // "&destinationx=" + String.valueOf(destination_longitude) +
            // "&destinationy=" + String.valueOf(destination_latitude) +
            // "&startdate=" + standard_commute_startdate
            // + "&enddate=" + standard_commute_enddate
            // + "&starttime=" + standard_commute_starttime
            // + "&endtime=" + standard_commute_endtime + "&weekrepeat=" +
            // weekrepeat + "&supplycar=" + supplycar;

            Log.e("commute_URL", commute_baseurl);
            // Instantiate the RequestQueue.
            // Request a string response from the provided URL.
            StringRequest stringRequest = new StringRequest(Request.Method.POST, commute_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            Log.d("commute_result", response);
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                requestok = json1.getBoolean("result");
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                            if (requestok == true) {

                                if (carinfochoosing_type == 1) {
                                    // add
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 1);
                                    // end!
                                } else {
                                    // update
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 2);
                                    // end!
                                }

                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "true");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            } else {
                                // Toast errorinfo =
                                // Toast.makeText(getApplicationContext(),
                                // "", Toast.LENGTH_LONG);
                                // errorinfo.show();
                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "false");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            }
                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("commute_result", error.getMessage(), error);
                            commute_result = null;
                            // Toast errorinfo = Toast.makeText(null,
                            // "", Toast.LENGTH_LONG);
                            // errorinfo.show();
                            Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                            sure.putExtra(getString(R.string.request_response), "false");
                            sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(sure);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    // POSTgetParams

                    // start
                    try {
                        test_date = primary_date.parse(commute_startdate);
                        standard_commute_startdate = standard_date.format(test_date);
                        test_date = primary_date.parse(commute_enddate);
                        standard_commute_enddate = standard_date.format(test_date);
                        test_date = primary_time.parse(commute_starttime);
                        standard_commute_starttime = standard_time.format(test_date);
                        test_date = primary_time.parse(commute_endtime);
                        standard_commute_endtime = standard_time.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    // end!

                    Map<String, String> params = new HashMap<String, String>();
                    params.put(getString(R.string.uri_phonenum), commute_phonenum);
                    params.put(getString(R.string.uri_startplacex), String.valueOf(startplace_longitude));
                    params.put(getString(R.string.uri_startplacey), String.valueOf(startplace_latitude));
                    params.put(getString(R.string.uri_startplace), startplace.getText().toString());
                    params.put(getString(R.string.uri_destinationx), String.valueOf(destination_longitude));
                    params.put(getString(R.string.uri_destinationy), String.valueOf(destination_latitude));
                    params.put(getString(R.string.uri_destination), endplace.getText().toString());
                    params.put(getString(R.string.uri_startdate), standard_commute_startdate);
                    params.put(getString(R.string.uri_enddate), standard_commute_enddate);
                    params.put(getString(R.string.uri_starttime), standard_commute_starttime);
                    params.put(getString(R.string.uri_endtime), standard_commute_endtime);
                    params.put(getString(R.string.uri_weekrepeat), weekrepeat);
                    params.put(getString(R.string.uri_supplycar), supplycar);
                    // Log.w("phonemum", commute_phonenum);
                    // Log.w("startplacex",
                    // String.valueOf(startplace_longitude));
                    // Log.w("startdate", standard_commute_startdate);
                    // Log.w("starttime", standard_commute_starttime);
                    // Log.w("weekrepeat",weekrepeat );
                    // Log.w("supplycar",supplycar );
                    // Log.w("enddate",standard_commute_enddate );

                    return params;
                }
            };

            queue.add(stringRequest);

        }
    });

    startplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseAddressActivity.class), 1);
        }
    });

    endplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseArrivalActivity.class), 2);
        }
    });

    increase.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum++;
            s1.setText("" + sum);
            confirm();
        }
    });

    decrease.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum--;
            if (sum < 0) {
                sum = 0;
            }
            s1.setText("" + sum);
            confirm();
        }
    });

    startdate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG);
        }

    });

    enddate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG01);

        }
    });

    earlystarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG);
        }
    });

    latestarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG01);

        }
    });
}

From source file:com.ubuntuone.android.files.service.UpDownService.java

public void notifyRoamingSoAutoUploadDisabled() {
    final String title = "Roaming, Auto Upload disabled";
    final String text = "To enable, change your settings.";
    Notification notification = new NotificationCompat.Builder(this).setOngoing(false)
            .setTicker("Roaming, Auto Upload disabled").setSmallIcon(R.drawable.stat_sys_upload_anim0)
            .setOnlyAlertOnce(true).setAutoCancel(true).getNotification();

    final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(PreferencesActivity.AUTOUPLOAD_SCREEN, 1);
    final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_AUTOUPLOAD_SCREEN,
            intent, 0);//from w w w  .jav  a 2  s.com
    notification.setLatestEventInfo(UpDownService.this, title, text, pi);

    notificationManager.notify(R.id.stat_roaming_autoupload_off_id, notification);
}

From source file:com.android.mms.transaction.MessagingNotification.java

private static final Intent getClickIntent(Context context, boolean isSms, long threadId) {
    Intent intent;/* w  ww.  j av a2s  .c o  m*/
    if (!MessageUtils.isMailboxMode()) {
        intent = ComposeMessageActivity.createIntent(context, threadId);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(MessageUtils.EXTRA_KEY_NEW_MESSAGE_NEED_RELOAD, true);
    } else if (isSms) {
        intent = new Intent(context, MailBoxMessageContent.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } else if (DownloadManager.getInstance().isAuto()) {
        intent = new Intent(context, MobilePaperShowActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } else {
        // Else case: for MMS not downloaded.
        intent = new Intent(context, MailBoxMessageList.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(MessageUtils.MAIL_BOX_ID, MailBoxMessageList.TYPE_INBOX);
    }
    return intent;
}