Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

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

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        Log.w(TAG, "Restored state");
        mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME);
    } else {/*from www. j  a va  2 s .c  om*/
        mOriginalSettings = new Bundle();
    }

    mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName());
    mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Intent intent = getIntent();
    String action = intent.getAction();
    Log.d(TAG, "ByodHelperActivity.onCreate: " + action);

    // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning.
    if (action.equals(ACTION_PROFILE_PROVISIONED)) {
        // Jump back to CTS verifier with result.
        Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS);
        response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
        startActivityInPrimary(response);
        // Queried by CtsVerifier in the primary side using startActivityForResult.
    } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) {
        Intent response = new Intent();
        response.putExtra(EXTRA_PROVISIONED, isProfileOwner());
        setResult(RESULT_OK, response);
        // Request to delete work profile.
    } else if (action.equals(ACTION_REMOVE_MANAGED_PROFILE)) {
        if (isProfileOwner()) {
            Log.d(TAG, "Clearing cross profile intents");
            mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent);
            mDevicePolicyManager.wipeData(0);
            showToast(R.string.provisioning_byod_profile_deleted);
        }
    } else if (action.equals(ACTION_INSTALL_APK)) {
        boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false);
        boolean wasAllowed = getAllowNonMarket();

        // Update permission to install non-market apps
        setAllowNonMarket(allowNonMarket);
        mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed);

        // Request to install a non-market application- easiest way is to reinstall ourself
        final Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE)
                .setData(Uri.parse("package:" + getPackageName()))
                .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true).putExtra(Intent.EXTRA_RETURN_RESULT, true);
        startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE);

        // Not yet ready to finish- wait until the result comes back
        return;
        // Queried by CtsVerifier in the primary side using startActivityForResult.
    } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) {
        final boolean intentFiltersSetForManagedIntents = new IntentFiltersTestHelper(this)
                .checkCrossProfileIntentFilters(IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED);
        setResult(intentFiltersSetForManagedIntents ? RESULT_OK : RESULT_FAILED, null);
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) {
        // We need the camera permission to send the image capture intent.
        grantCameraPermissionToSelf();
        Intent captureImageIntent = getCaptureImageIntent();
        Pair<File, Uri> pair = getTempUri("image.jpg");
        mImageFile = pair.first;
        mImageUri = pair.second;
        captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
        if (captureImageIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE);
        } else {
            Log.e(TAG, "Capture image intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)
            || action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) {
        // We need the camera permission to send the video capture intent.
        grantCameraPermissionToSelf();
        Intent captureVideoIntent = getCaptureVideoIntent();
        int videoCaptureRequestId;
        if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) {
            mVideoUri = getTempUri("video.mp4").second;
            captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
            videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT;
        } else {
            videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT;
        }
        if (captureVideoIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureVideoIntent, videoCaptureRequestId);
        } else {
            Log.e(TAG, "Capture video intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) {
        Intent captureAudioIntent = getCaptureAudioIntent();
        if (captureAudioIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(captureAudioIntent, REQUEST_AUDIO_CAPTURE);
        } else {
            Log.e(TAG, "Capture audio intent could not be resolved in managed profile.");
            showToast(R.string.provisioning_byod_capture_media_error);
            finish();
        }
        return;
    } else if (ACTION_KEYGUARD_DISABLED_FEATURES.equals(action)) {
        final int value = intent.getIntExtra(EXTRA_PARAMETER_1,
                DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE);
        mDevicePolicyManager.setKeyguardDisabledFeatures(mAdminReceiverComponent, value);
    } else if (ACTION_LOCKNOW.equals(action)) {
        mDevicePolicyManager.lockNow();
        setResult(RESULT_OK);
    } else if (action.equals(ACTION_TEST_NFC_BEAM)) {
        Intent testNfcBeamIntent = new Intent(this, NfcTestActivity.class);
        testNfcBeamIntent.putExtras(intent);
        startActivity(testNfcBeamIntent);
        finish();
        return;
    } else if (action.equals(ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)) {
        sendIntentInsideChooser(new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_PERSONAL));
    } else if (action.equals(ACTION_TEST_APP_LINKING_DIALOG)) {
        mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                UserManager.ALLOW_PARENT_PROFILE_APP_LINKING);
        Intent toSend = new Intent(Intent.ACTION_VIEW);
        toSend.setData(Uri.parse("http://com.android.cts.verifier"));
        sendIntentInsideChooser(toSend);
    } else if (action.equals(ACTION_SET_USER_RESTRICTION)) {
        final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1);
        if (restriction != null) {
            mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                    restriction);
        }
    } else if (action.equals(ACTION_CLEAR_USER_RESTRICTION)) {
        final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1);
        if (restriction != null) {
            mDevicePolicyManager.clearUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(),
                    restriction);
        }
    } else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) {
        handleLocationAction();
        return;
    } else if (action.equals(ACTION_NOTIFICATION)) {
        showNotification(Notification.VISIBILITY_PUBLIC);
    } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) {
        mDevicePolicyManager.lockNow();
        showNotification(Notification.VISIBILITY_PRIVATE);
    } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) {
        mNotificationManager.cancel(NOTIFICATION_ID);
    } else if (ACTION_TEST_SELECT_WORK_CHALLENGE.equals(action)) {
        mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, Color.BLUE);
        mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent,
                getResources().getString(R.string.provisioning_byod_confirm_work_credentials_header));
        startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD));
    } else if (ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS.equals(action)) {
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        Intent launchIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null);
        startActivity(launchIntent);
    } else if (ACTION_SET_ORGANIZATION_INFO.equals(action)) {
        if (intent.hasExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME)) {
            final String organizationName = intent
                    .getStringExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME);
            mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, organizationName);
        }
        final int organizationColor = intent.getIntExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_COLOR,
                mDevicePolicyManager.getOrganizationColor(mAdminReceiverComponent));
        mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, organizationColor);
    } else if (ACTION_TEST_PARENT_PROFILE_PASSWORD.equals(action)) {
        startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD));
    }
    // This activity has no UI and is only used to respond to CtsVerifier in the primary side.
    finish();
}

From source file:uf.edu.encDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.encdetail_activity);
    context = this.getApplicationContext();
    TextView tv = null;//from   ww  w . j ava 2s  . c o m
    SeekBar sb = null;
    Button b = null;
    Bundle bundle = this.getIntent().getExtras();
    Log.i("TAG", "encDetailActivity:onCreate,  Max Trust =" + getString(R.string.TrustSliderMax));
    MaxTrust = Integer.parseInt(getString(R.string.TrustSliderMax)) / 2;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                //Okay clicked.
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                //No button clicked
                break;
            }
        }
    };

    //builder.setMessage("Are you sure?").setPositiveButton("Okay", dialogClickListener);

    final EncUser encUser = (EncUser) bundle.getSerializable("userdata");
    final ArrayList<String> Address = (ArrayList<String>) bundle.getSerializable("useraddress");
    if (encUser == null) {
        Log.i(TAG, "encDetailsActivity: parameter received was null");
    }
    //Name
    tv = (TextView) findViewById(R.id.encdetail_name);
    tv.setText(encUser.Name);
    //Mac
    tv = (TextView) findViewById(R.id.encdetail_mac);
    tv.setText(encUser.Mac);
    tv.setOnClickListener(new View.OnClickListener() { //event listener to fetch more info abt a user.
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Registration Lookup requested for " + encUser.Mac);
            Toast.makeText(encDetailActivity.this, "Please wait while we lookup the information",
                    Toast.LENGTH_LONG).show();
            String data = getData(encUser.Mac).replace('\n', ' ').trim();
            String message = null;
            if (data.substring(0, 5).compareToIgnoreCase("Error") == 0) {
                message = "No more info available for this device";
            } else {
                data = data.replace('\'', ' '); //remove single quotes
                data = data.replace(')', ' ').trim(); //remove closing brackets.
                StringTokenizer tok = new StringTokenizer(data.substring(1), ",");
                message = "Name: " + tok.nextToken() + " " + tok.nextToken() + "\n" + "Email: "
                        + tok.nextToken() + "\n" + "Profile: " + tok.nextToken();
            }
            //Toast.makeText(encDetailActivity.this, getData(encUser.Mac), Toast.LENGTH_LONG).show();
            builder.setMessage(message);
            builder.show();
        }
    });
    //lasttime
    tv = (TextView) findViewById(R.id.encdetail_lasttime);
    tv.setText((new java.util.Date((long) encUser.lastEncounterTime * 1000)).toString());
    tv.setOnClickListener(new View.OnClickListener() { //To generate graph
        @Override
        public void onClick(View v) {
            Intent intent = barchartIntent(encUser.timeSeries, encUser.Mac, encUser.Name);
            startActivity(intent);
        }
    });

    //tv.setText(Integer.toString(encUser.lastEncounterTime)); 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_FE);
    tv.setText(Float.toString(encUser.score[0]));
    tv = (TextView) findViewById(R.id.encdetail_decayFE);
    tv.setText(Float.toString(encUser.decayScore[0] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //DE
    tv = (TextView) findViewById(R.id.encdetail_DE);
    tv.setText(Float.toString(encUser.score[1]));
    tv = (TextView) findViewById(R.id.encdetail_decayDE);
    tv.setText(Float.toString(encUser.decayScore[1] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //LV-C
    tv = (TextView) findViewById(R.id.encdetail_LVC);
    tv.setText(Float.toString(encUser.score[2]));
    //LV-D
    tv = (TextView) findViewById(R.id.encdetail_LVD);
    tv.setText(Float.toString(encUser.score[3]));
    //combined 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_comb);
    tv.setText(Float.toString(encUser.score[4]));

    //check the toggle button state

    sb = (SeekBar) findViewById(R.id.encdetail_trust);
    //since Seekbar cannot go into -ve values we scale -Max Value to Max Value
    sb.setProgress(encUser.trusted + MaxTrust);
    tv = (TextView) findViewById(R.id.CurrentTrustValue);
    tv.setText(TrustArray[encUser.trusted + MaxTrust]);

    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        TextView tvcurrent = (TextView) findViewById(R.id.CurrentTrustValue);

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser == true) {
                Log.i(TAG, "encDetailsActivity: User changed value for Trust to " + progress);
                encUser.trusted = progress - MaxTrust;
                tvcurrent.setText(TrustArray[progress]);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }
    });

    b = (Button) findViewById(R.id.encdetail_done);
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            iTrust.cd.write("Trust Value changed for this user :" + encUser.Mac + " to:" + encUser.trusted);
            Bundle bundle = new Bundle();
            Intent returnIntent = new Intent();
            bundle.putSerializable("Object", encUser);
            returnIntent.putExtras(bundle);
            //returnIntent.putExtra("TrustSet",trustResult);
            encDetailActivity.this.setResult(Activity.RESULT_OK, returnIntent);
            finish();
        }
    });

    //show map
    tv = (TextView) findViewById(R.id.encdetail_map);
    tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Map lookup for encounter user " + encUser.Mac);
            Bundle bundle = new Bundle();
            Intent newIntent = new Intent(context, map.class);
            bundle.putSerializable("useraddress", Address);
            newIntent.putExtras(bundle);
            startActivity(newIntent);
        }
    });

}

From source file:com.acc.android.util.widget.adapter.ImageAdapter.java

public ImageAdapter(final Context context,
        // List<Cphoto> cPhotos,
        Gallery gallery, BitmapProviderManager bitmapProviderManager, ACCFileCallback accFileCallback,
        // boolean useOldShowImage,
        boolean useGalleryDeleteAction, boolean isBig) {
    this.context = context;
    this.gallery = gallery;
    // this.cPhotos = new ArrayList<Cphoto>();
    this.isBig = isBig;
    // if (fileDownloadManager == null) {
    // Handler fileDownloadListener = new Handler() {
    // @Override//from  w  ww .  j av  a2s .  c  o m
    // public void handleMessage(final Message msg) {
    // ImageAdapter.this.notifyDataSetChanged();
    // }
    // };
    // // ;
    // fileDownloadManager = new FileDownloadManager(context,
    // fileDownloadListener);
    // }
    this.accFileCallback = accFileCallback;
    this.bitmapProviderManager = bitmapProviderManager;
    // this.gallery.setAdapter(this);
    this.gallery.setVisibility(View.GONE);
    // this.fileDownloadManager = fileDownloadManager;
    this.initGalleryAciton(
            // useOldShowImage,
            useGalleryDeleteAction);
    this.onSingleTapListener = new OnSingleTapListener() {

        @Override
        public void onSingleTap() {
            Intent intent = new Intent();
            intent.putExtras(IntentUtil.getBundle(ACCALibConstant.KEY_BUNDLE_ACC_FILE_S,
                    ImageAdapter.this.getTransImageData()));
            Activity contextActivity = (Activity) context;
            contextActivity.setResult(Activity.RESULT_OK, intent);
            contextActivity.finish();
        }
    };
    this.initImageData();
}

From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java

private void scan(JSONArray data) {
    if (mPendingOperation) {
        return;//from www . ja v  a  2  s .c  om
    }
    mPendingOperation = true;
    mHandler.start();

    final Bundle bundle = new Bundle();
    try {
        bundle.putString(ScanditSDKParameterParser.paramAppKey, data.getString(0));
    } catch (JSONException e) {
        Log.e("ScanditSDK", "Function called through Java Script contained illegal objects.");
        e.printStackTrace();
        return;
    }

    if (data.length() > 1) {
        // We extract all options and add them to the intent extra bundle.
        try {
            setOptionsOnBundle(data.getJSONObject(1), bundle);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    if (bundle.containsKey(ScanditSDKParameterParser.paramContinuousMode)) {
        mContinuousMode = bundle.getBoolean(ScanditSDKParameterParser.paramContinuousMode);
    }

    ScanditLicense.setAppKey(bundle.getString(ScanditSDKParameterParser.paramAppKey));
    ScanditSDKGlobals.usedFramework = "phonegap";

    if (bundle.containsKey(ScanditSDKParameterParser.paramPortraitMargins)
            || bundle.containsKey(ScanditSDKParameterParser.paramLandscapeMargins)) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(bundle);
                mBarcodePicker = new SearchBarBarcodePicker(cordova.getActivity(), settings);
                mBarcodePicker.setOnScanListener(ScanditSDK.this);
                mBarcodePicker.setOnSearchBarListener(ScanditSDK.this);
                mLayout = new RelativeLayout(cordova.getActivity());

                ViewGroup viewGroup = getViewGroupToAddTo();
                if (viewGroup != null) {
                    viewGroup.addView(mLayout);
                }

                Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
                ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(),
                        display.getHeight());

                RelativeLayout.LayoutParams rLayoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
                mLayout.addView(mBarcodePicker, rLayoutParams);
                adjustLayout(bundle, 0);

                if (bundle.containsKey(ScanditSDKParameterParser.paramPaused)
                        && bundle.getBoolean(ScanditSDKParameterParser.paramPaused)) {
                    mBarcodePicker.startScanning(true);
                } else {
                    mBarcodePicker.startScanning();
                }
            }
        });

    } else {
        ScanditSDKResultRelay.setCallback(this);
        Intent intent = new Intent(cordova.getActivity(), ScanditSDKActivity.class);
        intent.putExtras(bundle);
        cordova.startActivityForResult(this, intent, 1);
    }
}

From source file:com.petrodevelopment.dice.external.Router.java

/**
 * Open a map'd URL set using {@link #map(String, Class)} or {@link #map(String, RouterCallback)}
 * @param url The URL; for example, "users/16" or "groups/5/topics/20"
 * @param extras The {@link Bundle} which contains the extras to be assigned to the generated {@link Intent}
 * @param context The context which is used in the generated {@link Intent}
 *//*from  w w  w  .j  ava  2s  . co  m*/
public void open(String url, Bundle extras, Context context) {
    if (context == null) {
        throw new ContextNotProvided("You need to supply a context for Router " + this.toString());
    }
    RouterParams params = this.paramsForUrl(url);
    RouterOptions options = params.routerOptions;
    if (options.getCallback() != null) {
        RouteContext routeContext = new RouteContext(params.openParams, extras, context);

        options.getCallback().run(routeContext);
        return;
    }

    Intent intent = this.intentFor(context, params);
    if (intent == null) {
        // Means the options weren't opening a new activity
        return;
    }
    if (extras != null) {
        intent.putExtras(extras);
    }
    context.startActivity(intent);
}

From source file:com.procasy.dubarah_nocker.gcm.MyGcmPushReceiver.java

/**
 * Called when message is received./*  w w w.ja v a2 s.  co  m*/
 *
 * @param from   SenderID of the sender.
 * @param bundle Data bundle containing message data as key/value pairs.
 *               For Set of keys use data.keySet().
 */

@Override
public void onMessageReceived(String from, Bundle bundle) {

    MainActivity.getInstance().updateNotification();

    try {

        Log.e("notify_gcm", "success , type = " + bundle.toString());

        switch (bundle.getString(GCM_TAG)) {
        case "GENERAL": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, GENERAL_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "HELP": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, HELP_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            JSONObject content = new JSONObject(bundle.getString("content"));
            JSONObject hr = content.getJSONObject("hr");
            JSONArray album = content.getJSONArray("album");
            System.out.println(content.getInt("hr_id"));
            System.out.println(content.toString());
            Bundle bundle1 = new Bundle();
            bundle1.putString("hr_id", hr.getString("hr_id"));
            bundle1.putString("hr_user_id", hr.getString("hr_user_id"));
            bundle1.putString("hr_description", hr.getString("hr_description"));
            bundle1.putString("hr_est_date", hr.getString("hr_est_date"));
            bundle1.putString("hr_est_time", hr.getString("hr_est_time"));
            bundle1.putString("hr_skill_id", hr.getString("hr_skill_id"));
            bundle1.putString("hr_ua_id", hr.getString("hr_ua_id"));
            bundle1.putString("hr_voice_record", hr.getString("hr_voice_record"));
            bundle1.putString("hr_language", hr.getString("hr_language"));
            bundle1.putString("hr_lat", hr.getString("hr_lat"));
            bundle1.putString("hr_lon", hr.getString("hr_lon"));
            bundle1.putString("hr_address", hr.getString("hr_address"));
            ArrayList<String> array = new ArrayList<>();
            for (int i = 0; i < album.length(); i++) {
                JSONObject object = album.getJSONObject(i);
                array.add(object.getString("ahr_img"));
            }
            bundle1.putStringArrayList("album", array);

            Intent intent = (new Intent(getApplicationContext(), JobRequestActivity.class));
            intent.putExtras(bundle1);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getApplicationContext().startActivity(intent);

            break;
        }

        case "APPOINTEMENT": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, APPOINTEMENT_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "QOUTA_USER": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, USER_Qouta_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "QOUTA_NOCKER": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, Nocker_Qouta_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.facebook.android.friendsmash.HomeFragment.java

void startGame(String userId) {
    Intent i = new Intent(getActivity(), GameActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString("user_id", userId);
    i.putExtras(bundle);
    startActivityForResult(i, 0);/* ww w .j  a v a2s. c om*/
}

From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java

/**
 * Menu actions/*from   w w  w  .ja  va2 s .  c  om*/
 * @param menuItem
 */
@Override
public boolean onOptionsItemSelected(final MenuItem menuItem) {

    switch (menuItem.getItemId()) {

    case MENU_ITEM_REFRESH:
        mShowDialog = true;
        new GetNextTramTimes().execute();
        return true;

    case MENU_ITEM_FAVOURITE:
        mStarButton = (CompoundButton) findViewById(R.id.stopStar);
        Favourite favourite = new Favourite(mStop, mRoute);
        boolean isFavourite = mFavouriteList.isFavourite(favourite);
        mFavouriteList.toggleFavourite(favourite);
        mStarButton.setChecked(!isFavourite);
        return true;

    case MENU_ITEM_MAP:
        // Map view
        Bundle bundle = new Bundle();
        StopsList mStopList = new StopsList();
        mStopList.add(mStop);
        bundle.putParcelable("stopslist", mStopList);
        Intent intent = new Intent(StopDetailsActivity.this, StopMapActivity.class);
        intent.putExtras(bundle);
        startActivityForResult(intent, 1);
        return true;
    }

    return false;
}

From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUserId <= 0)
        return false;
    switch (item.getItemId()) {
    case MENU_VIEW_PROFILE: {
        openUserProfile(getActivity(), mSelectedUserId, mSelectedUserId, null);
        break;/*from   w ww.  ja va 2 s  . c  om*/
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(INTENT_ACTION_SET_COLOR);
        final Bundle bundle = new Bundle();
        bundle.putInt(Accounts.USER_COLOR, mSelectedColor);
        intent.putExtras(bundle);
        startActivityForResult(intent, REQUEST_SET_COLOR);
        break;
    }
    case MENU_SET_AS_DEFAULT: {
        setDefaultAccount(mSelectedUserId);
        break;
    }
    case MENU_DELETE: {
        mResolver.delete(Accounts.CONTENT_URI, Accounts.USER_ID + " = " + mSelectedUserId, null);
        // Also delete tweets related to the account we previously
        // deleted.
        mResolver.delete(Statuses.CONTENT_URI, Statuses.ACCOUNT_ID + " = " + mSelectedUserId, null);
        mResolver.delete(Mentions.CONTENT_URI, Mentions.ACCOUNT_ID + " = " + mSelectedUserId, null);
        mResolver.delete(DirectMessages.Inbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + mSelectedUserId,
                null);
        mResolver.delete(DirectMessages.Outbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + mSelectedUserId,
                null);
        if (getActivatedAccountIds(getActivity()).length > 0) {
            getLoaderManager().restartLoader(0, null, AccountsFragment.this);
        } else {
            getActivity().finish();
        }
        break;
    }
    }
    return super.onContextItemSelected(item);
}

From source file:com.ayyayo.g.Push.FIRMessagingService.java

private void sendNotification(Map<String, String> data) {

    // handle notification here
    /*/*from   w  ww  .  j a v  a 2 s  .  c o m*/
    * types of notification 1. result update 2. circular update 3. student
    * corner update 4. App custom update 5. Custom Message 6. Notice from
    * College custom
    */
    int num = ++NOTIFICATION_ID;
    Bundle msg = new Bundle();
    for (String key : data.keySet()) {
        Log.e(key, data.get(key));
        msg.putString(key, data.get(key));
    }

    pref = getSharedPreferences("UPDATE_INSTANCE", MODE_PRIVATE);
    edit = pref.edit();
    Intent backIntent;
    Intent intent = null;
    PendingIntent pendingIntent = null;
    backIntent = new Intent(getApplicationContext(), App.class);
    backIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    SharedPreferences sp;
    Editor editor;

    switch (Integer.parseInt(msg.getString("type"))) {

    case 1:
        break;
    case 2:

        backIntent = new Intent(getApplicationContext(), DailogeNotice.class);
        backIntent.putExtras(msg);

        stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)
        // stackBuilder.addParentStack(AppUpdate.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(backIntent);
        pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT);

        break;
    case 3:
        backIntent = new Intent(getApplicationContext(), CustomeWebView.class);

        backIntent.putExtras(msg);
        // The stack builder object will contain an artificial back stack
        // for the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out
        // of
        // your application to the Home screen.
        stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)
        // stackBuilder.addParentStack(AppUpdate.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(backIntent);
        pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT);

        break;

    case 4:
        backIntent = new Intent(getApplicationContext(), App.class);

        // The stack builder object will contain an artificial back stack
        // for the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out
        // of
        // your application to the Home screen.
        stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)
        // stackBuilder.addParentStack(AppUpdate.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(backIntent);
        pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT);

        DatabaseHandler db = new DatabaseHandler(getApplicationContext(), jsonConverter);
        db.addContact(new News(msg.getString("title"), msg.getString("msg"), msg.getString("link"),
                msg.getString("image")), DatabaseHandler.TABLE_NEWS);

        Intent intent_notify = new Intent(FCMActivity.NEW_NOTIFICATION);
        intent_notify.putExtra("DUMMY", "MUST");
        sendBroadcast(intent_notify);
        break;
    default:
        break;
    }
    if (!is_noty) {
        mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

        mBuilder.setSmallIcon(R.drawable.ic_stat_fcm).setContentTitle(msg.getString("title"))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg.getString("msg").toString()))
                .setAutoCancel(true).setContentText(msg.getString("msg"));

        if (Integer.parseInt(msg.getString("type")) != 1) {
            mBuilder.setContentIntent(pendingIntent);
        }

        mBuilder.setDefaults(Notification.DEFAULT_ALL);

        mNotificationManager.notify(++NOTIFICATION_ID, mBuilder.build());
    }
}