Example usage for android.content Intent setFlags

List of usage examples for android.content Intent setFlags

Introduction

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

Prototype

public @NonNull Intent setFlags(@Flags int flags) 

Source Link

Document

Set special flags controlling how this intent is handled.

Usage

From source file:foundme.uniroma2.it.professore.Connection.java

@Override
protected void onPostExecute(String result[]) {
    if (result[0].equalsIgnoreCase(Variables_it.NO_INTERNET)) {
        if (enProgressDialog)
            caricamento.dismiss();//from ww  w . java 2  s  .co  m
        Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
        return;
    }
    if (enProgressDialog) {
        caricamento.dismiss();
        if (!returnMessage.equalsIgnoreCase(Variables_it.NAME)
                || result[0].equalsIgnoreCase(Variables_it.ERROR)) {
            if (!returnMessage.equalsIgnoreCase("") && !returnMessage.equalsIgnoreCase(Variables_it.NO_MSG)) {
                Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
            }
        }
    }
    if (returnMessage.equalsIgnoreCase(Variables_it.NO_MSG)) {
        ReadMessageActivity.populateView(result);
    } else if (returnMessage.equalsIgnoreCase(Variables_it.DEL_MSG_OK)) {
        try {
            ReadMessageActivity.getMsg(toDo, false);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else if (toDo.equalsIgnoreCase(Variables_it.GET)) {
        HomeActivity.populateView(result);
    } else if (returnMessage.equalsIgnoreCase(Variables_it.SEND_MSG_OK)
            && toDo.equalsIgnoreCase(Variables_it.MSGS)) {
        ((Activity) context).finish();
    } else if (returnMessage.equalsIgnoreCase(Variables_it.NAME) && toDo.equalsIgnoreCase(Variables_it.LOG)
            && !result[0].equalsIgnoreCase(Variables_it.ERROR)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, LoginActivity.getuser());
        SPEditor.setPass(pref, LoginActivity.getpass());
        Intent intent = new Intent(context, HomeActivity.class);
        intent.putExtra(Variables_it.TAG, LoginActivity.gettag());
        intent.putExtra(Variables_it.NAME, result[0]);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.FINISH)) {
        ((Activity) context).finish();
        try {
            HomeActivity.getCourse(true);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.CHANGEP)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setPass(pref, ChangePswActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.REGIS)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, RegistrationActivity.getmail());
        SPEditor.setPass(pref, RegistrationActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.DELACC)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.delete(pref);
        Intent intent = new Intent(context, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    }

    else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.HOME)) {
        try {
            HomeActivity.getCourse(false);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.parking.swipelistview.sample.adapters.MallAdapter.java

private void goToPayScreen(String mallName, long hargaParkir, String slotName, String bookingId) {
    Intent i = new Intent(ctx, InputCreditCardActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    i.putExtra("mallName", mallName);
    i.putExtra("hargaParkir", hargaParkir);
    i.putExtra("slotName", slotName);
    i.putExtra("bookingId", bookingId);
    ctx.startActivity(i);//from   w w w  .j  av  a  2 s  .  co  m
}

From source file:com.cleanwiz.applock.service.LockService.java

private void userLock(String pkgName) {
    AppLockApplication.getInstance().clearAllActivity();
    LogUtil.d("demo3", "user  lock");
    Intent intent = new Intent(AppLockApplication.getInstance(), UserUnlockActivity.class);
    intent.putExtra(MyConstants.LOCK_PACKAGE_NAME, pkgName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);//from  w w w  .  j a  va 2  s. c om
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java

@Override
public void handleDirectMessage(Context context, Contact from, JSONObject obj) {
    String packageName = obj.optString(PACKAGE_NAME);
    String arg = obj.optString(ARG);
    Intent launch = new Intent();
    launch.setAction(Intent.ACTION_MAIN);
    launch.addCategory(Intent.CATEGORY_LAUNCHER);
    launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg);
    launch.putExtra("creator", false);
    launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launch.setPackage(packageName);/*from w ww  .  j a v  a2s. c o  m*/
    final PackageManager mgr = context.getPackageManager();
    List<ResolveInfo> resolved = mgr.queryIntentActivities(launch, 0);
    if (resolved == null || resolved.size() == 0) {
        Toast.makeText(context, "Could not find application to handle invite", Toast.LENGTH_SHORT).show();
        return;
    }
    ActivityInfo info = resolved.get(0).activityInfo;
    launch.setComponent(new ComponentName(info.packageName, info.name));
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch,
            PendingIntent.FLAG_CANCEL_CURRENT);

    (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received from " + from.name,
            "Click to launch application.", contentIntent);
}

From source file:com.jeremyhaberman.playgrounds.WebPlaygroundDAO.java

@Override
public Collection<Playground> getAll(Context context) {
    // synchronized (Swingset.initPlaygroundLock) {
    playgrounds = new ArrayList<Playground>();
    String result = swingset.getResources().getString(R.string.error);
    HttpURLConnection httpConnection = null;
    Log.d(TAG, "getPlaygrounds()");

    try {//from  w  ww.  ja v a 2s.c  o m
        // Check if task has been interrupted
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }

        // Build query
        URL url = new URL("http://swingsetweb.appspot.com/playground");
        httpConnection = (HttpURLConnection) url.openConnection();
        httpConnection.setConnectTimeout(15000);
        httpConnection.setReadTimeout(15000);
        StringBuilder response = new StringBuilder();

        if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            // Read results from the query
            BufferedReader input = new BufferedReader(
                    new InputStreamReader(httpConnection.getInputStream(), "UTF-8"));
            String strLine = null;
            while ((strLine = input.readLine()) != null) {
                response.append(strLine);
            }
            input.close();

        }

        // Parse to get translated text
        JSONArray jsonPlaygrounds = new JSONArray(response.toString());
        int numOfPlaygrounds = jsonPlaygrounds.length();

        JSONObject jsonPlayground = null;

        for (int i = 0; i < numOfPlaygrounds; i++) {
            jsonPlayground = jsonPlaygrounds.getJSONObject(i);
            playgrounds.add(toPlayground(jsonPlayground));
        }

    } catch (Exception e) {
        Log.e(TAG, "Exception", e);
        Intent errorIntent = new Intent(context, Playgrounds.class);
        errorIntent.putExtra("Exception", e.getLocalizedMessage());
        errorIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(errorIntent);
    } finally {
        if (httpConnection != null) {
            httpConnection.disconnect();
        }
    }

    // all done
    Log.d(TAG, "   -> returned " + result);
    return playgrounds;
    // }
}

From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java

private void triggerBuzzing(Place place) {
    Place.Buzz buzz = place.getBuzzObject();
    if (buzz.isActivated() || buzz.getBuzzCount() <= 0)
        return;/* w  w  w. j  a va  2s.com*/

    buzz.setActivated(true);

    Intent i = new Intent();
    i.setClass(this, BuzzActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);
    showArrivalNotification();
    Log.d(TAG, "Starting vibration...");
    new Thread(new VibrationThread(place)).start();
}

From source file:com.jeremyhaberman.playgrounds.WebPlaygroundDAO.java

@Override
public Collection<? extends Playground> getWithin(Context context, GeoPoint topLeft, GeoPoint bottomRight,
        int maxQuantity) {
    playgrounds = new ArrayList<Playground>();
    String result = swingset.getResources().getString(R.string.error);
    HttpURLConnection httpConnection = null;
    Log.d(TAG, "getPlaygrounds()");

    try {/*ww w .ja  va  2  s .c  o  m*/
        // Check if task has been interrupted
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }

        // Build query
        URL url = new URL("http://swingsetweb.appspot.com/playground?" + TYPE_PARAM + "=" + WITHIN + "&"
                + TOP_LEFT_LATITUDE_PARAM + "=" + topLeft.getLatitudeE6() / 1E6 + "&" + TOP_LEFT_LONGITUDE_PARAM
                + "=" + topLeft.getLongitudeE6() / 1E6 + "&" + BOTTOM_RIGHT_LATITUDE_PARAM + "="
                + bottomRight.getLatitudeE6() / 1E6 + "&" + BOTTOM_RIGHT_LONGITUDE_PARAM + "="
                + bottomRight.getLongitudeE6() / 1E6);
        httpConnection = (HttpURLConnection) url.openConnection();
        httpConnection.setConnectTimeout(15000);
        httpConnection.setReadTimeout(15000);
        StringBuilder response = new StringBuilder();

        if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            // Read results from the query
            BufferedReader input = new BufferedReader(
                    new InputStreamReader(httpConnection.getInputStream(), "UTF-8"));
            String strLine = null;
            while ((strLine = input.readLine()) != null) {
                response.append(strLine);
            }
            input.close();

        }

        // Parse to get translated text
        JSONArray jsonPlaygrounds = new JSONArray(response.toString());
        int numOfPlaygrounds = jsonPlaygrounds.length();

        JSONObject jsonPlayground = null;

        for (int i = 0; i < numOfPlaygrounds; i++) {
            jsonPlayground = jsonPlaygrounds.getJSONObject(i);
            playgrounds.add(toPlayground(jsonPlayground));
        }

    } catch (Exception e) {
        Log.e(TAG, "Exception", e);
        Intent errorIntent = new Intent(context, Playgrounds.class);
        errorIntent.putExtra("Exception", e.getLocalizedMessage());
        errorIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(errorIntent);
    } finally {
        if (httpConnection != null) {
            httpConnection.disconnect();
        }
    }

    Log.d(TAG, "   -> returned " + result);
    return playgrounds;
}

From source file:it.uniroma2.foundme.studente.Connection.java

@Override
protected void onPostExecute(String result[]) {
    if (result[0].equalsIgnoreCase(Variables_it.NO_INTERNET)) {
        if (enProgressDialog)
            caricamento.dismiss();//w w  w . j  a  v a  2  s. c o  m
        Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
        return;
    }
    if (enProgressDialog) {
        caricamento.dismiss();
        if (!returnMessage.equalsIgnoreCase(Variables_it.NAME)
                || result[0].equalsIgnoreCase(Variables_it.ERROR)) {
            if (!returnMessage.equalsIgnoreCase(Variables_it.SHOW)
                    && !returnMessage.equalsIgnoreCase(Variables_it.FOLLOW)
                    && !returnMessage.equalsIgnoreCase(Variables_it.UNFOLLOW)
                    && !returnMessage.equalsIgnoreCase(Variables_it.MSG)
                    && !returnMessage.equalsIgnoreCase(Variables_it.MID)) {
                Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
            }
        }
    }
    if (toDo.equalsIgnoreCase(Variables_it.GET)) {
        if (returnMessage.equalsIgnoreCase(Variables_it.SHOW))
            ShowCourseActivity.populateView(result);
        if (returnMessage.equalsIgnoreCase(Variables_it.FOLLOW))
            FollowCourseActivity.populateView(result);
        if (returnMessage.equalsIgnoreCase(Variables_it.UNFOLLOW))
            UnFollowCourseActivity.populateView(result);
        if (returnMessage.equalsIgnoreCase(Variables_it.MSG))
            ReadMessageActivity.populateView(result);
        if (returnMessage.equalsIgnoreCase(Variables_it.MID))
            ShowMsgActivity.populateView(result);
    } else if (returnMessage.equalsIgnoreCase(Variables_it.NAME) && toDo.equalsIgnoreCase(Variables_it.LOG)
            && !result[0].equalsIgnoreCase(Variables_it.ERROR)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, LoginActivity.getuser());
        SPEditor.setPass(pref, LoginActivity.getpass());
        SPEditor.setGCM(pref, result[2]);
        SPEditor.setID(pref, result[1]);
        Intent intent = new Intent(context, HomeActivity.class);
        intent.putExtra(Variables_it.NAME, result[0]);
        intent.putExtra(Variables_it.ID, result[1]);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    } else if (toDo.equalsIgnoreCase(Variables_it.INFOC)) {
        try {
            CourseActivity.setFields(json_data.getString(Variables_it.CFU),
                    json_data.getString(Variables_it.NAME_1), json_data.getString(Variables_it.NAME_2),
                    json_data.getInt(Variables_it.NOTIFICATION));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.CHANGEP)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setPass(pref, ChangePswActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.REGIS)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, RegistrationActivity.getmail());
        SPEditor.setPass(pref, RegistrationActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.DELACC)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.delete(pref);
        Intent intent = new Intent(context, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    }

    else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.UNFOLLOW)) {
        try {
            UnFollowCourseActivity.getCourse(true);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.wso2.app.catalog.api.ApplicationManager.java

/**
 * Installs an application to the device.
 *
 * @param fileUri - File URI should be passed in as a String.
 *//*from  w  ww  .  j a  v a 2 s  . c om*/
public void startInstallerIntent(Uri fileUri) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(fileUri, resources.getString(R.string.application_mgr_mime));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:com.anhuioss.crowdroid.activity.MoreFunctionActivity.java

private void confirmLogoutDialog() {
    AlertDialog.Builder dlg = new AlertDialog.Builder(this);
    dlg.setTitle(R.string.logout);/*from w  ww.jav a  2 s .  c  o  m*/
    dlg.setMessage(getResources().getString(R.string.wheter_to_logout))
            .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    //
                    NotificationManager notificationManager = (NotificationManager) getSystemService(
                            NOTIFICATION_SERVICE);
                    notificationManager.cancelAll();

                    Intent i = new Intent(MoreFunctionActivity.this, LoginActivity.class);
                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    i.putExtra("autoLogin", false);
                    startActivity(i);
                    //                        android.os.Process
                    //                              .killProcess(android.os.Process.myPid());
                }
            }).setNegativeButton(getResources().getString(R.string.cancel),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    })
            .create().show();

}