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:org.wso2.emm.agent.services.operation.OperationManager.java

/**
 * Ring the device./*from   w ww  . ja va 2s .  c om*/
 *
 * @param operation - Operation object.
 */
public void ringDevice(org.wso2.emm.agent.beans.Operation operation) {
    operation.setStatus(resources.getString(R.string.operation_value_completed));
    resultBuilder.build(operation);
    Intent intent = new Intent(context, AlertActivity.class);
    intent.putExtra(resources.getString(R.string.intent_extra_type),
            resources.getString(R.string.intent_extra_ring));
    intent.putExtra(resources.getString(R.string.intent_extra_message_text),
            resources.getString(R.string.intent_extra_stop_ringing));
    intent.setFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);

    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "Ringing is activated on the device");
    }
}

From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java

public void onBackPressed() {
    Intent setIntent = new Intent(Intent.ACTION_MAIN);
    setIntent.addCategory(Intent.CATEGORY_HOME);
    setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(setIntent);/*  w w  w . j av a 2s. c  o m*/
}

From source file:org.gaeproxy.GAEProxyService.java

@Override
public void onCreate() {
    super.onCreate();

    mShutdownReceiver = new BroadcastReceiver() {
        @Override/*w  ww . j a  va  2  s.c  o m*/
        public void onReceive(Context context, Intent intent) {
            stopSelf();
        }
    };
    IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
    registerReceiver(mShutdownReceiver, filter);

    EasyTracker.getTracker().trackEvent("service", "start", getVersionName(), 0L);

    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    settings = PreferenceManager.getDefaultSharedPreferences(this);

    Intent intent = new Intent(this, GAEProxyActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
    notification = new Notification();

    try {
        mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature);
        mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature);
    } catch (NoSuchMethodException e) {
        // Running on an older platform.
        mStartForeground = mStopForeground = null;
    }

    try {
        mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature);
    } catch (NoSuchMethodException e) {
        throw new IllegalStateException("OS doesn't have Service.startForeground OR Service.setForeground!");
    }
}

From source file:com.orange.oidc.secproxy_service.HttpOpenidConnect.java

public boolean getTokens(Context ctx, String id, String login) {

    if (mOcp == null)
        return false;

    try {//from w  w  w  .  java2s. c  o m

        String requestObject = null;
        String authorization_endpoint = null;
        try {

            // retrieve openid config
            JSONObject json = getHttpJSON(mOcp.m_server_url + openIdConfigurationUrl);
            if (json == null) {
                Logd(TAG, "could not get openid-configuration on server : " + mOcp.m_server_url);
                return false;
            }

            // get authorization end_point
            authorization_endpoint = json.optString("authorization_endpoint");

            Logd(TAG, "authorization_endpoint : " + authorization_endpoint);

            // TAZTAG : no use to define request object if key jwt is not used ?
            if (mUsePrivateKeyJWT) {
                // get jwks_uri of the server
                String jwks_uri = json.optString("jwks_uri");
                if (jwks_uri == null || jwks_uri.length() < 1) {
                    Logd(TAG, "could not get jwks_uri from openid-configuration on server : "
                            + mOcp.m_server_url);
                    return false;
                }
                Logd(TAG, "jwks_uri : " + jwks_uri);

                // get jwks
                String jwks = getHttpString(jwks_uri);
                if (jwks == null || jwks.length() < 1) {
                    Logd(TAG, "could not get jwks_uri content from : " + jwks_uri);
                    return false;
                }
                Logd(TAG, "jwks : " + jwks);

                // extract public key
                PublicKey serverPubKey = KryptoUtils.pubKeyFromJwk(jwks);
                if (serverPubKey == null) {
                    Logd(TAG, "could not extract public key from jwk : " + jwks);
                    return false;
                }

                // get oidc request object
                requestObject = secureProxy.getOidcRequestObject(mOcp.m_server_url, mOcp.m_client_id,
                        mOcp.m_scope, serverPubKey);
                Logd(TAG, "secureStorage requestObject : " + requestObject);
            }

        } catch (Exception ee) {
            // error generating request object
            ee.printStackTrace();
            return false;
        }

        // build post parameters
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
        nameValuePairs.add(new BasicNameValuePair("redirect_uri", mOcp.m_redirect_uri));
        nameValuePairs.add(new BasicNameValuePair("response_type", "code"));
        nameValuePairs.add(new BasicNameValuePair("scope", mOcp.m_scope));

        nameValuePairs.add(new BasicNameValuePair("client_id", secureProxy.getClientId()));

        //         nameValuePairs.add(new BasicNameValuePair("nonce",         mOcp.m_nonce));
        nameValuePairs.add(new BasicNameValuePair("nonce", "1234567890"));
        if (!isEmpty(requestObject)) {
            nameValuePairs.add(new BasicNameValuePair("request", requestObject));
        }
        nameValuePairs.add(new BasicNameValuePair("prompt", "consent"));

        // get URL encoded string from list of key value pairs
        String postParams = getQuery(nameValuePairs);

        Log.d(TAG, "get URL encoded string from list of key value pairs : " + postParams);

        // launch webview

        // init intent
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(ctx, WebViewActivity.class);

        // prepare request parameters
        intent.putExtra("id", id);

        intent.putExtra("server_url", authorization_endpoint);
        intent.putExtra("redirect_uri", mOcp.m_redirect_uri);
        intent.putExtra("client_id", mOcp.m_client_id);
        if (login != null)
            intent.putExtra("login", login);

        intent.putExtra("postParams", postParams);

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_NO_ANIMATION);

        // display webview
        ctx.startActivity(intent);

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:github.popeen.dsub.activity.SubsonicActivity.java

protected void exit() {
    if (((Object) this).getClass() != SubsonicFragmentActivity.class) {
        Intent intent = new Intent(this, SubsonicFragmentActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
        Util.startActivityWithoutTransition(this, intent);
    } else {/* w ww  .j  ava2 s. c o m*/
        finished = true;
        this.stopService(new Intent(this, DownloadService.class));
        this.finish();
    }
}

From source file:com.justone.android.main.MainActivity.java

public void shareOnClick(View view) {
    String shareTitle = "";
    String shareContent = "    ";
    if (tabs.getCurrentTabTag() == "home tab") {
        shareTitle = "home tab";
        shareContent = shareContent + ((TextView) this.findViewById(R.id.fPage_tView)).getText().toString()
                + ((TextView) this.findViewById(R.id.imageBelow_tView)).getText().toString()
                + "()  " + ((TextView) this.findViewById(R.id.home_share_url)).getText().toString();
    } else if (tabs.getCurrentTabTag() == "QA Tab") {
        shareTitle = "QA Tab";
        shareContent = shareContent + ((TextView) this.findViewById(R.id.question_content)).getText().toString()
                + " -  ()  "
                + ((TextView) this.findViewById(R.id.qa_share_url)).getText().toString();

    } else if (tabs.getCurrentTabTag() == "list tab") {
        shareTitle = "list tab";
        shareContent = shareContent + ""
                + ((TextView) this.findViewById(R.id.one_content_title)).getText().toString() + " by "
                + ((TextView) this.findViewById(R.id.one_content_author)).getText().toString()
                + "- ()  "
                + ((TextView) this.findViewById(R.id.list_share_url)).getText().toString();

    }// ww w.  ja  v  a  2  s  .  c om

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    // intent.setPackage("com.sina.weibo");
    intent.putExtra(Intent.EXTRA_SUBJECT, "");
    //intent.putExtra(Intent.EXTRA_TEXT, shareTitle+"   VOL.516   () http://caodan.org/516-photo.html ");
    intent.putExtra(Intent.EXTRA_TEXT, shareContent);
    intent.putExtra(Intent.EXTRA_TITLE, shareTitle);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(Intent.createChooser(intent, ""));
}

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent returnp = new Intent(CommuteActivity.this, PersonalCenterActivity.class);
        returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(returnp);/*w ww.  j a va2s .  co  m*/
        return false;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:github.popeen.dsub.activity.SubsonicActivity.java

public void startFragmentActivity(String fragmentType) {
    Intent intent = new Intent();
    intent.setClass(SubsonicActivity.this, SubsonicFragmentActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (!"".equals(fragmentType)) {
        intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
    }/*  www  . j a  v  a2 s. c  o m*/
    if (lastSelectedPosition != 0) {
        intent.putExtra(Constants.FRAGMENT_POSITION, lastSelectedPosition);
    }
    startActivity(intent);
    finish();
}

From source file:app.sunstreak.yourpisd.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Pass the event to ActionBarDrawerToggle, if it returns
    // true, then it has handled the app icon touch event
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/* w  w w  .  j  a  v a2 s.c  om*/
    // Handle your other action bar items...
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.log_out:
        session = null;
        // attendanceTask.cancel(true);
        // attendanceTask = null;
        Editor editor = getSharedPreferences("LoginActivity", Context.MODE_PRIVATE).edit();
        editor.putBoolean("auto_login", false);
        editor.commit();

        Intent intent = new Intent(this, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra("show", true);
        startActivity(intent);
        return true;
    case R.id.credits:
        Intent intentCred1 = new Intent(this, CreditActivity.class);
        startActivity(intentCred1);
        return true;
    // case R.id.refresh:
    // dg.clearData();
    // Intent intentR = new Intent(this, LoginActivity.class);
    // intentR.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    // intentR.putExtra("Refresh", true);
    // startActivity(intentR);
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.vuze.android.remote.SessionInfo.java

private void activateOpenOptionsDialog(long torrentID, Map<?, ?> mapTorrent,
        List<String> listOpenOptionHashes) {
    if (listOpenOptionHashes.size() == 0) {
        return;/*w  w w . j  av  a 2 s .c om*/
    }
    String hashString = MapUtils.getMapString(mapTorrent, TransmissionVars.FIELD_TORRENT_HASH_STRING, null);
    for (String waitingOn : listOpenOptionHashes) {
        if (!waitingOn.equalsIgnoreCase(hashString)) {
            continue;
        }

        long numFiles = MapUtils.getMapLong(mapTorrent, TransmissionVars.FIELD_TORRENT_FILE_COUNT, 0);
        if (AndroidUtils.DEBUG) {
            Log.d(TAG, "Found waiting torrent " + hashString + " with " + numFiles + " files");
        }

        if (numFiles <= 0) {
            continue;
        }

        Context context = currentActivity == null ? VuzeRemoteApp.getContext() : currentActivity;
        Intent intent = new Intent(Intent.ACTION_VIEW, null, context, TorrentOpenOptionsActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(SessionInfoManager.BUNDLE_KEY, getRemoteProfile().getID());
        intent.putExtra("TorrentID", torrentID);

        try {
            context.startActivity(intent);

            remoteProfile.removeOpenOptionsWaiter(hashString);
            saveProfile();
            return;
        } catch (Throwable t) {
            // I imagine if we are trying to start an intent with 
            // a dead context, we'd get some sort of exception..
            // or does it magically create the activity anyway?
            VuzeEasyTracker.getInstance().logErrorNoLines(t);
        }
    }
}