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:com.nextgis.maplibui.mapui.NGWVectorLayerUI.java

@Override
public void showAttributes() {
    Intent settings = new Intent(mContext, AttributesActivity.class);
    settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    settings.putExtra(ConstantsUI.KEY_LAYER_ID, getId());
    mContext.startActivity(settings);/*from   w  w  w.ja v a2  s  .  c  o  m*/
}

From source file:com.nbos.phonebook.sync.syncadapter.SyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {//from w ww.ja  va2  s .  c  o m
    if (isSyncing) {
        Log.i(tag, "isSyncing, returning");
        return;
    }
    isSyncing = true;
    this.account = account;
    try {
        // use the account manager to request the credentials
        String phoneNumber = accountManager.getUserData(account, Constants.PHONE_NUMBER_KEY);
        authtoken = accountManager.blockingGetAuthToken(account, Constants.AUTHTOKEN_TYPE,
                true /* notifyAuthFailure */);
        Log.i(tag, "phone number is: " + phoneNumber + ", authtoken: " + authtoken);
        // fetch updates from the sample service over the cloud
        boolean valid = Net.checkValidAccount(account, authtoken,
                accountManager.getUserData(account, Constants.PHONE_NUMBER_KEY));
        // start the confirmation activity if not valid

        Log.i(tag, "valid account is: " + valid);
        if (!valid) {
            final Intent intent = new Intent(context, ValidationActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(Net.PARAM_USERNAME, account.name);
            intent.putExtra(Net.PARAM_PASSWORD, authtoken);
            intent.putExtra(Net.PARAM_PHONE_NUMBER, phoneNumber);
            intent.putExtra(Net.PARAM_PHONE_NUMBER, phoneNumber);
            context.startActivity(intent);
            isSyncing = false;
            return;
        }
        doSync();
    } catch (Exception e) {
        notifyListeners(e.getMessage());
        e.printStackTrace();
    } finally {
        isSyncing = false;
    }
}

From source file:samples.piggate.com.piggateInfoDemo.InfoActivity.java

public void backButton() {
    Intent slideactivity = new Intent(InfoActivity.this, Activity_Logged.class);
    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    Bundle bndlanimation = ActivityOptions
            .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright).toBundle();
    startActivity(slideactivity, bndlanimation);
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.NavigateToLinkInteractionView.java

@Override
public void doOnCreate(Activity activity, Bundle savedInteraction) {
    boolean success = false;
    try {/* w w w  .j ava2s.  c o  m*/
        String url = interaction.getUrl();
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

        switch (interaction.getTarget()) {
        case New:
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            break;
        case Self:
            // Nothing
            break;
        default:
            break;
        }

        activity.startActivity(intent);
        success = true;
    } catch (ActivityNotFoundException e) {
        Log.w("NavigateToLink Error: ", e);
    } finally {
        JSONObject data = new JSONObject();
        try {
            data.put(NavigateToLinkInteraction.KEY_URL, interaction.getUrl());
            data.put(NavigateToLinkInteraction.KEY_TARGET, interaction.getTarget().lowercaseName());
            data.put(NavigateToLinkInteraction.EVENT_KEY_SUCCESS, success);
        } catch (JSONException e) {
            Log.e("Error creating Event data object.", e);
        }
        EngagementModule.engageInternal(activity, interaction, NavigateToLinkInteraction.EVENT_NAME_NAVIGATE,
                data.toString());
        // Always finish this Activity.
        activity.finish();
    }
}

From source file:com.nextgis.maplibui.mapui.NGWVectorLayerUI.java

@Override
public void changeProperties(Context context) {
    Intent settings = new Intent(context, VectorLayerSettingsActivity.class);
    settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    settings.putExtra(ConstantsUI.KEY_LAYER_ID, getId());
    context.startActivity(settings);//  w  ww.  j  a  v  a 2 s .  c  o  m
}

From source file:com.thedamfr.facebook_dashclock_ext.ExampleExtension.java

@Override
protected void onUpdateData(int reason) {
    Session fbSession = Session.getActiveSession();
    if (fbSession == null) {
        Resources resources = this.getResources();
        AssetManager assetManager = resources.getAssets();
        Properties properties = new Properties();
        // Read from the /assets directory
        try {// w  w  w .  j ava  2s. co  m
            InputStream inputStream = assetManager.open("facebook.properties");
            properties.load(inputStream);
            System.out.println("The properties are now loaded");
            //System.out.println("properties: " + properties);
        } catch (IOException e) {
            System.err.println("Failed to open facebook property file");
            e.printStackTrace();
        }

        Session session = new Session.Builder(this).setApplicationId(properties.getProperty("app_id", ""))
                .build();
        Session.setActiveSession(session);
        fbSession = session;
    }
    if (fbSession != null && !fbSession.isOpened()) {
        Intent intent = new Intent(this, RefreshSessionActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
    if (fbSession.isOpened()) {
        Request notificationsRequest = Request.newGraphPathRequest(fbSession, "me/notifications",
                new Request.Callback() {

                    @Override
                    public void onCompleted(Response response) {
                        GraphObject object = response.getGraphObject();
                        if (object != null) {
                            JSONArray notifications = (JSONArray) object.getProperty("data");
                            if (notifications.length() >= 1) {
                                // Publish the extension data update.
                                String title = null;
                                String link = null;
                                try {
                                    title = ((JSONObject) notifications.get(0)).getString("title");
                                    link = ((JSONObject) notifications.get(0)).getString("link");
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                    title = "Can't read title";
                                }
                                publishUpdate(new ExtensionData().visible(true).icon(R.drawable.icon)
                                        .status("New Content")
                                        .expandedTitle(notifications.length() + "  notifications")
                                        .expandedBody(title)
                                        .clickIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(link))));

                            } else {
                                publishUpdate(new ExtensionData().visible(false).status("No Content"));
                            }
                        } else {
                            publishUpdate(new ExtensionData().visible(false).status("No Content"));
                        }

                    }
                });

        notificationsRequest.executeAsync();
    }

}

From source file:com.aegiswallet.actions.CurrencyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.currency_view);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(R.layout.aegis_send_actionbar);

    TextView titleTextView = (TextView) findViewById(R.id.action_bar_title_text);
    titleTextView.setText(getString(R.string.currencies_activity_label));

    ImageButton backButton = (ImageButton) findViewById(R.id.action_bar_icon_back);
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w  w . j a v  a  2s .c  o m*/
        public void onClick(View view) {
            Intent openMainActivity = new Intent(context, MainActivity.class);
            openMainActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            context.startActivity(openMainActivity);
            finish();
        }
    });

    ArrayList<CurrencyPojo> currencies = new ArrayList<CurrencyPojo>();

    JSONObject jsonObject = BasicUtils.parseJSONData(getApplicationContext(),
            Constants.BLOCKCHAIN_CURRENCY_FILE_NAME);

    if (jsonObject != null) {

        Iterator i = jsonObject.keys();
        while (i.hasNext()) {

            try {
                String currency = (String) i.next();
                JSONObject detailObj = jsonObject.getJSONObject(currency);
                CurrencyPojo newPojo = new CurrencyPojo(currency, detailObj.getDouble("last"),
                        detailObj.getString("symbol"));

                currencies.add(newPojo);
            } catch (JSONException e) {
                Log.e("Currency Activity", "JSON Exception " + e.getMessage());
            }
        }

        String currentCurrency = prefs.getString(Constants.CURRENCY_PREF_KEY, null);
        CurrencyPojo firstPojo = currencies.get(0);

        for (int j = 0; j < currencies.size(); j++) {
            CurrencyPojo pojo = currencies.get(j);
            if (pojo.getCurrency().equals(currentCurrency)) {
                currencies.set(0, pojo);
                currencies.set(j, firstPojo);
            }
        }

    }

    CurrencyAdapter currencyAdapter = new CurrencyAdapter(this, R.layout.currency_list_item, currencies, prefs);

    ListView transactionListView = (ListView) findViewById(R.id.currency_list);
    transactionListView.setAdapter(currencyAdapter);

}

From source file:de.micmun.android.workdaystarget.DaysLeftService.java

/**
 * Updates the days to target.// www  . j ava2s .  com
 */
private void updateDays() {
    AppWidgetManager appManager = AppWidgetManager.getInstance(this);
    ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class);
    int[] appIds = appManager.getAppWidgetIds(cName);

    DayCalculator dayCalc = new DayCalculator();
    if (!isOnline()) {
        try {
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            Log.e(TAG, "Interrupted: " + e.getLocalizedMessage());
        }
    }

    for (int appId : appIds) {
        PrefManager pm = new PrefManager(this, appId);
        Calendar target = pm.getTarget();
        boolean[] chkDays = pm.getCheckedDays();
        int days = pm.getLastDiff();

        if (isOnline()) {
            try {
                days = dayCalc.getDaysLeft(target.getTime(), chkDays);
                Map<String, Object> saveMap = new HashMap<String, Object>();
                Long diff = Long.valueOf(days);
                saveMap.put(PrefManager.KEY_DIFF, diff);
                pm.save(saveMap);
            } catch (JSONException e) {
                Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage());
            }
        } else {
            Log.e(TAG, "No internet connection!");
        }
        RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout);
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
        String targetStr = df.format(target.getTime());
        rv.setTextViewText(R.id.target, targetStr);
        String dayStr = String.format(Locale.getDefault(), "%d %s", days,
                getResources().getString(R.string.unit));
        rv.setTextViewText(R.id.dayCount, dayStr);

        // put widget id into intent
        Intent configIntent = new Intent(this, ConfigActivity.class);
        configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
        configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent);

        // update widget
        appManager.updateAppWidget(appId, rv);
    }
}

From source file:com.playhaven.android.diagnostic.test.PHTestCase.java

@SuppressWarnings("unchecked")
protected ACTIVITY startActivitySync(Class<ACTIVITY> clazz) {
    Intent intent = new Intent(getInstrumentation().getTargetContext(), clazz);
    intent.setFlags(intent.getFlags() | FLAG_ACTIVITY_NEW_TASK);
    return (ACTIVITY) getInstrumentation().startActivitySync(intent);
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_SingIn.java

public void backButton() {
    Intent slideactivity = new Intent(Activity_SingIn.this, Activity_Main.class);
    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    Bundle bndlanimation = ActivityOptions
            .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright).toBundle();
    startActivity(slideactivity, bndlanimation);
}