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:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Creates a system notification./*from w  w w . j  a va  2 s .  c om*/
 *    
 * @param context            Context.
 * @param notSound            Enable or disable the sound
 * @param notSoundRawId         Custom raw sound id. If enabled and not set 
 *                         default notification sound will be used. Set to -1 to 
 *                         default system notification.
 * @param multipleNot         Setting to True allows showing multiple notifications.
 * @param groupMultipleNotKey   If is set, multiple notifications can be grupped by this key.
 * @param notAction            Action for this notification
 * @param notTitle            Title
 * @param notMessage         Message
 * @param notClazz            Class to be executed
 * @param extras            Extra information
 * 
 */
public static void notification_generate(Context context, boolean notSound, int notSoundRawId,
        boolean multipleNot, String groupMultipleNotKey, String notAction, String notTitle, String notMessage,
        Class<?> notClazz, Bundle extras, boolean wakeUp) {

    try {
        int iconResId = notification_getApplicationIcon(context);
        long when = System.currentTimeMillis();

        Notification notification = new Notification(iconResId, notMessage, when);

        // Hide the notification after its selected
        notification.flags |= Notification.FLAG_AUTO_CANCEL;

        if (notSound) {
            if (notSoundRawId > 0) {
                try {
                    notification.sound = Uri.parse("android.resource://"
                            + context.getApplicationContext().getPackageName() + "/" + notSoundRawId);
                } catch (Exception e) {
                    if (LOG_ENABLE) {
                        Log.w(TAG, "Custom sound " + notSoundRawId + "could not be found. Using default.");
                    }
                    notification.defaults |= Notification.DEFAULT_SOUND;
                    notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                }
            } else {
                notification.defaults |= Notification.DEFAULT_SOUND;
                notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            }
        }

        Intent notificationIntent = new Intent(context, notClazz);
        notificationIntent.setAction(notClazz.getName() + "." + notAction);
        if (extras != null) {
            notificationIntent.putExtras(extras);
        }

        //Set intent so it does not start a new activity
        //
        //Notes:
        //   - The flag FLAG_ACTIVITY_SINGLE_TOP makes that only one instance of the activity exists(each time the
        //      activity is summoned no onCreate() method is called instead, onNewIntent() is called.
        //  - If we use FLAG_ACTIVITY_CLEAR_TOP it will make that the last "snapshot"/TOP of the activity it will 
        //     be this called this intent. We do not want this because the HOME button will call this "snapshot". 
        //     To avoid this behaviour we use FLAG_ACTIVITY_BROUGHT_TO_FRONT that simply takes to foreground the 
        //     activity.
        //
        //See http://developer.android.com/reference/android/content/Intent.html           
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);

        PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        int REQUEST_UNIQUE_ID = 0;
        if (multipleNot) {
            if (groupMultipleNotKey != null && groupMultipleNotKey.length() > 0) {
                REQUEST_UNIQUE_ID = groupMultipleNotKey.hashCode();
            } else {
                if (random == null) {
                    random = new Random();
                }
                REQUEST_UNIQUE_ID = random.nextInt();
            }
            PendingIntent.getActivity(context, REQUEST_UNIQUE_ID, notificationIntent,
                    PendingIntent.FLAG_ONE_SHOT);
        }

        notification.setLatestEventInfo(context, notTitle, notMessage, intent);

        //This makes the device to wake-up is is idle with the screen off.
        if (wakeUp) {
            powersaving_wakeUp(context);
        }

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        //We check if the sound is disabled to enable just for a moment
        AudioManager amanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        int previousAudioMode = amanager.getRingerMode();
        ;
        if (notSound && previousAudioMode != AudioManager.RINGER_MODE_NORMAL) {
            amanager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }

        notificationManager.notify(REQUEST_UNIQUE_ID, notification);

        //We restore the sound setting
        if (previousAudioMode != AudioManager.RINGER_MODE_NORMAL) {
            //We wait a little so sound is played
            try {
                Thread.sleep(3000);
            } catch (Exception e) {
            }
        }
        amanager.setRingerMode(previousAudioMode);

        Log.d(TAG, "Android Notification created.");

    } catch (Exception e) {
        if (LOG_ENABLE)
            Log.e(TAG, "The notification could not be created (" + e.getMessage() + ")", e);
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openStatus(final Activity activity, final ParcelableStatus status) {
    if (activity == null || status == null)
        return;/*from  w w w. j  a  va2  s .c  o m*/
    final long account_id = status.account_id, status_id = status.status_id;
    final Bundle bundle = new Bundle();
    bundle.putParcelable(INTENT_KEY_STATUS, status);
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment details_fragment = dual_pane_activity.getDetailsFragment();
        if (details_fragment instanceof StatusFragment && details_fragment.isAdded()) {
            ((StatusFragment) details_fragment).displayStatus(status);
            dual_pane_activity.bringRightPaneToFront();
        } else {
            final Fragment fragment = new StatusFragment();
            final Bundle args = new Bundle(bundle);
            args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
            args.putLong(INTENT_KEY_STATUS_ID, status_id);
            fragment.setArguments(args);
            dual_pane_activity.showAtPane(DualPaneActivity.PANE_RIGHT, fragment, true);
        }
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_STATUS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
        final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());

        intent.putExtras(bundle);
        activity.startActivity(intent);
    }
}

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

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mUser == null || mService == null)
        return false;
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO: {
        takePhoto();//  w ww .j  a v  a 2s  .  c  o m
        break;
    }
    case MENU_ADD_IMAGE: {
        pickImage();
        break;
    }
    case MENU_BANNER_TAKE_PHOTO: {
        takeBannerPhoto();
        break;
    }
    case MENU_BANNER_ADD_IMAGE: {
        pickBannerImage();
        break;
    }
    case MENU_TRACKING: {
        UpdateTrackingTask task = new UpdateTrackingTask(!tracking);
        task.execute();
        break;
    }
    case MENU_BLOCK: {
        if (mService == null || mFriendship == null) {
            break;
        }
        if (mFriendship.isSourceBlockingTarget()) {
            mService.destroyBlock(mAccountId, mUser.getId());
        } else {
            mService.createBlock(mAccountId, mUser.getId());
        }
        break;
    }
    case MENU_REPORT_SPAM: {
        mService.reportSpam(mAccountId, mUser.getId());
        break;
    }
    case MENU_MUTE_USER: {
        final String screen_name = mUser.getScreenName();
        final Uri uri = Filters.Users.CONTENT_URI;
        final ContentValues values = new ContentValues();
        final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME,
                Context.MODE_PRIVATE).edit();
        final ContentResolver resolver = getContentResolver();
        values.put(Filters.Users.TEXT, screen_name);
        resolver.delete(uri, Filters.Users.TEXT + " = '" + screen_name + "'", null);
        resolver.insert(uri, values);
        editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit();
        Toast.makeText(getActivity(), R.string.user_muted, Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_MENTION: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final String name = mUser.getName();
        final String screen_name = mUser.getScreenName();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putString(INTENT_KEY_TEXT, "@" + screen_name + " ");
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name);
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_SEND_DIRECT_MESSAGE: {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(mAccountId));
        builder.appendQueryParameter(QUERY_PARAM_CONVERSATION_ID, String.valueOf(mUser.getId()));
        startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
        break;
    }
    case MENU_VIEW_ON_TWITTER: {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://twitter.com/" + mUser.getScreenName()));
        startActivity(browserIntent);
        break;
    }
    case MENU_WANT_RETWEETS: {
        updateFriendship();
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER, new ParcelableUser(mUser, mAccountId));
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(INTENT_ACTION_SET_COLOR);
        startActivityForResult(intent, REQUEST_SET_COLOR);
        break;
    }
    case MENU_CLEAR_COLOR: {
        clearUserColor(getActivity(), mUserId);
        updateUserColor();
        break;
    }
    }
    return true;
}

From source file:com.dwdesign.tweetings.activity.SettingsActivity.java

@Override
public boolean onPreferenceClick(final Preference preference) {
    final String key = preference.getKey();
    final Bundle args = new Bundle();
    final int res_id;
    if (KEY_CUSTOM_TABS.equals(key)) {
        if (isDualPaneMode()) {
            final Fragment fragment = new CustomTabsFragment();
            showFragment(fragment, true);
        } else {//ww  w .j a  va  2 s  .  com
            final Intent intent = new Intent(INTENT_ACTION_CUSTOM_TABS);
            intent.setPackage(getPackageName());
            startActivity(intent);
        }
        return true;
    } else if (KEY_ABOUT.equals(key)) {
        if (isDualPaneMode()) {
            res_id = R.xml.about;
        } else {
            final Intent intent = new Intent(INTENT_ACTION_ABOUT);
            intent.setPackage(getPackageName());
            startActivity(intent);
            return true;
        }
    } else if (KEY_EXTENSIONS.equals(key)) {
        if (isDualPaneMode()) {
            final Fragment fragment = new ExtensionsListFragment();
            showFragment(fragment, true);
        } else {
            final Intent intent = new Intent(INTENT_ACTION_EXTENSIONS);
            intent.setPackage(getPackageName());
            startActivity(intent);
        }
        return true;
    } else if (KEY_SETTINGS_APPEARANCE.equals(key)) {
        res_id = R.xml.settings_appearance;
    } else if (KEY_SETTINGS_CONTENT_AND_STORAGE.equals(key)) {
        res_id = R.xml.settings_content_and_storage;
    } else if (KEY_SETTINGS_NETWORK.equals(key)) {
        res_id = R.xml.settings_network;
    } else if (KEY_SETTINGS_COMPOSE.equals(key)) {
        res_id = R.xml.settings_compose;
    } else if (KEY_SETTINGS_REFRESH_AND_NOTIFICATIONS.equals(key)) {
        res_id = R.xml.settings_refresh_and_notifications;
    } else if (KEY_SETTINGS_WIDGET.equals(key)) {
        res_id = R.xml.settings_widget;
    } else if (KEY_SETTINGS_OTHER.equals(key)) {
        res_id = R.xml.settings_other;
    } else {
        res_id = -1;
    }
    if (res_id > 0) {
        args.putInt(INTENT_KEY_RESID, res_id);
        if (isDualPaneMode()) {
            final Fragment fragment = new SettingsDetailsFragment();
            fragment.setArguments(args);
            showFragment(fragment, true);
        } else {
            final Intent intent = new Intent(this, SettingsDetailsActivity.class);
            intent.putExtras(args);
            startActivity(intent);
        }
    }
    return true;
}

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

@SuppressLint({ "NewApi", "NewApi", "NewApi" })
@Override/*from ww w.ja v  a2 s . c  o m*/
public boolean onMenuItemClick(final MenuItem item) {
    if (mStatus == null)
        return false;
    final String text_plain = mStatus.text_plain;
    final String screen_name = mStatus.screen_name;
    final String name = mStatus.name;
    switch (item.getItemId()) {
    case MENU_SHARE: {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "@" + mStatus.screen_name + ": " + text_plain);
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case MENU_RETWEET: {
        if (isMyRetweet(mStatus)) {
            mService.destroyStatus(mAccountId, mStatus.retweet_id);
        } else {
            final long id_to_retweet = mStatus.is_retweet && mStatus.retweet_id > 0 ? mStatus.retweet_id
                    : mStatus.status_id;
            mService.retweetStatus(mAccountId, id_to_retweet);
        }
        break;
    }
    case MENU_TRANSLATE: {
        translate(mStatus);
        break;
    }
    case MENU_QUOTE_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_QUOTE: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_ADD_TO_BUFFER: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putBoolean(INTENT_KEY_IS_BUFFER, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final List<String> mentions = new Extractor().extractMentionedScreennames(text_plain);
        mentions.remove(screen_name);
        mentions.add(0, screen_name);
        bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()]));
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, text_plain);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name);
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_FAV: {
        if (mStatus.is_favorite) {
            mService.destroyFavorite(mAccountId, mStatusId);
        } else {
            mService.createFavorite(mAccountId, mStatusId);
        }
        break;
    }
    case MENU_COPY_CLIPBOARD: {
        final String textToCopy = "@" + mStatus.screen_name + ": " + mStatus.text_plain;
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
            android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(
                    Context.CLIPBOARD_SERVICE);
            clipboard.setText(textToCopy);
        } else {
            android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(
                    Context.CLIPBOARD_SERVICE);
            android.content.ClipData clip = android.content.ClipData.newPlainText("Status", textToCopy);
            clipboard.setPrimaryClip(clip);
        }
        Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_DELETE: {
        mService.destroyStatus(mAccountId, mStatusId);
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_STATUS, mStatus);
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    case MENU_MUTE_SOURCE: {
        final String source = HtmlEscapeHelper.unescape(mStatus.source);
        if (source == null)
            return false;
        final Uri uri = Filters.Sources.CONTENT_URI;
        final ContentValues values = new ContentValues();
        final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME,
                Context.MODE_PRIVATE).edit();
        final ContentResolver resolver = getContentResolver();
        values.put(Filters.TEXT, source);
        resolver.delete(uri, Filters.TEXT + " = '" + source + "'", null);
        resolver.insert(uri, values);
        editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit();
        Toast.makeText(getActivity(), getString(R.string.source_muted, source), Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(INTENT_ACTION_SET_COLOR);
        startActivityForResult(intent, REQUEST_SET_COLOR);
        break;
    }
    case MENU_CLEAR_COLOR: {
        clearUserColor(getActivity(), mStatus.user_id);
        updateUserColor();
        break;
    }
    case MENU_RECENT_TWEETS: {
        openUserTimeline(getActivity(), mAccountId, mStatus.user_id, mStatus.screen_name);
        break;
    }
    case MENU_FIND_RETWEETS: {
        openUserRetweetedStatus(getActivity(), mStatus.account_id,
                mStatus.retweet_id > 0 ? mStatus.retweet_id : mStatus.status_id);
        break;
    }
    default:
        return false;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

public void JSgoBack() {
    // TODO Auto-generated method stub
    DebugLog.d(TAG, "JSgoBack() mWebView.getUrl() = " + mWebView.getUrl());
    if (mWebView.getUrl() != null) {
        if (GameInfo.isErrorUrl(mWebView.getUrl())) {
            Bundle bundle = new Bundle();
            bundle.putInt("msgtype", Constants.HANDLER_UI_NOTIFY_EXIT_APP_SERVEER);
            bundle.putString("msgcontent", "Notify Exit Application");

            Intent intent = new Intent(Constants.RECEIVER_BROADCAST);
            intent.putExtras(bundle);

            if (mContext != null)
                mContext.sendBroadcast(intent);
        } else {//from   ww  w .  jav  a  2  s.  com
            DebugLog.d(TAG, "JSgoBack() javascript:history.back()");
            mWebView.loadUrl("javascript:history.back();");
        }
    }
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void exitApp(String jsonData) {
    String result = null;//from w w  w  .  ja  va 2  s .c om
    try {
        JSONObject json = new JSONObject(jsonData);
        String id = json.optString("id");
        String type = json.optString("type");

        Bundle bundle = new Bundle();
        bundle.putInt("msgtype", Constants.HANDLER_UI_NOTIFY_EXIT_APP_SERVEER);
        bundle.putString("msgcontent", "Notify Exit Application");

        Intent intent = new Intent(Constants.RECEIVER_BROADCAST);
        intent.putExtras(bundle);

        if (mContext != null)
            mContext.sendBroadcast(intent);
        else
            DebugLog.d(TAG, "mContext == null");

        result = "{" + "\"id\": \"" + id + "\"," + "\"type\": \"result\"," + "\"code\": \"200\","
                + "\"message\": \"success(200)\"" + "}";
    } catch (Exception e) {
        // TODO Auto-generated catch block
        DebugLog.d(TAG, "exception = " + e.getMessage());
        result = "{" + "\"code\": \"" + Constants.RESPONSE_500
                + "\",\"message\": \" player internal error(500) \"}";
    }

    this.ubiGCPlayerCallback("exitApp", result);
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void handleProhibitCheckAvailableNetwork(String jsonData) {
    JSONObject json;/*from  w w  w  .  ja va  2 s .c  o m*/
    try {
        json = new JSONObject(jsonData);
        mPlayId = json.optString("id");
        DebugLog.d(TAG, "handleProhibitCheckAvailableNetwork() enter");

        String result = "{\"code\": \"" + Constants.RESPONSE_500
                + "\",\"message\": \"Only allow to play game under LTE or WIFI.\"}";
        ubiGCPlayerCallback("checkAvailableNetwork", result);

        notifyClosePlayerWebJS();
        callJsUpdateStatus(Constants.RESPONSE_302);

        WebBrowser.sGameExitStatus = Constants.GAMEACTIVITY_ALERT_DIALOG_TYPE_NOT_LTEWIFI;
        DebugLog.d(TAG, "====prohibit play in 3G network=====");
        Utils.ShowOKPrompt(mContext, GameActivityRes.STRING_WARNING, GameActivityRes.STRING_NETWORKTYPE_WRN_3G,
                GameActivityRes.STRING_NETWORKTYPE_CLOSEAPK, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        LoadWebJsActivity.sGameingExitAndExitApp = true;
                        Bundle bundle = new Bundle();
                        bundle.putInt("msgtype", NotifyManagement.LOCAL_GAMEACTIVITY_RESULT);
                        Intent intent = new Intent(Constants.RECEIVER_BROADCAST);
                        intent.putExtras(bundle);
                        WebBrowser.this.mContext.sendBroadcast(intent);
                        dialog.dismiss();
                    }
                });
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        DebugLog.d(TAG, "excepion = " + e.getMessage());
    }

}

From source file:com.facebook.Session.java

private Intent getLoginActivityIntent(AuthorizationRequest request) {
    Intent intent = new Intent();
    intent.setClass(getStaticContext(), LoginActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let LoginActivity populate extras appropriately
    AuthorizationClient.AuthorizationRequest authClientRequest = request.getAuthorizationClientRequest();
    Bundle extras = LoginActivity.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}

From source file:com.fowlcorp.homebank4android.gui.AccountRecyclerAdapter.java

@Override
public void onBindViewHolder(final OperationViewHolder holder, final int position) {
    final Operation operation = listOperation.get(position);

    final Calendar myDate = Calendar.getInstance();
    myDate.clear();/*from   w w  w .ja  v a 2 s .c om*/
    myDate.setTime(operation.getDate().getTime());
    final SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.FRANCE);
    holder.getRootLayout().setOnClickListener(new OnClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(activity.getApplicationContext(), DetailedCardActivity.class);
            Bundle bdl = new Bundle();
            try {

                bdl.putString("Date", df.format(myDate.getTime()));
            } catch (Exception e) {
            }
            try {
                bdl.putString("Category",
                        (operation.getCategory().getParent() == null ? ""
                                : operation.getCategory().getParent().getName() + ": ")
                                + operation.getCategory().getName());
            } catch (Exception e) {
            }
            try {
                bdl.putString("Payee", operation.getPayee().getName());
            } catch (Exception e) {
            }
            try {
                bdl.putString("Wording", operation.getWording());
            } catch (Exception e) {
            }
            try {
                bdl.putString("Amount", String.valueOf(Round.roundAmount(operation.getAmount())));
            } catch (Exception e) {
            }
            try {
                bdl.putInt("Type", operation.getPayMode());
            } catch (Exception e) {
            }
            //                try {
            //                    intent.putExtra("Info", operation.getInfo());
            //                } catch (Exception e) {
            //                }
            try {
                bdl.putBoolean("Reconciled", operation.isReconciled());
            } catch (Exception e) {
            }
            try {
                bdl.putBoolean("Remind", operation.isRemind());
            } catch (Exception e) {
            }
            try {
                Log.d("Debug", String.valueOf(operation.isSplit()));
                bdl.putBoolean("Split", operation.isSplit());
            } catch (Exception e) {
            }
            try {
                bdl.putSerializable("Couple", operation.getSplits());
            } catch (Exception e) {
                e.printStackTrace();
            }

            intent.putExtras(bdl);

            //            Pair datePair = Pair.create(holder.getDate(), "date");
            //            Pair categoryPair = Pair.create(holder.getCategory(), "category");
            //            Pair wordingPair = Pair.create(holder.getWording(), "wording");
            //            Pair payeePair = Pair.create(holder.getPayee(), "payee");
            //            Pair amountPair = Pair.create(holder.getAmount(), "amount");
            Pair<View, String> cardPair = Pair.create((View) holder.getCard(), "card");
            //            Pair iconPair = Pair.create(holder.getMode(), "icon");
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
                    cardPair);
            ActivityCompat.startActivity(activity, intent, options.toBundle());
            //activity.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(activity).toBundle());
            //activity.startActivity(intent);
        }

    });

    try {
        holder.getDate().setText(activity.getString(R.string.Date) + " : " + df.format(myDate.getTime()));
    } catch (Exception e) {
    }
    try {
        holder.getPayee().setText(activity.getString(R.string.Payee) + " : " + operation.getPayee().getName());
    } catch (Exception e) {
    }
    try {
        holder.getWording().setText(activity.getString(R.string.Wording) + " : " + operation.getWording());
    } catch (Exception e) {
    }
    if (!operation.isSplit()) {
        holder.getSplitLinear().removeAllViews();
        holder.getUnSplitLinear().setVisibility(LinearLayout.VISIBLE);
        try {
            holder.getCategory()
                    .setText(activity.getString(R.string.Wording) + " : "
                            + (operation.getCategory().getParent() == null ? ""
                                    : operation.getCategory().getParent().getName() + ": ")
                            + operation.getCategory().getName());
        } catch (Exception e) {
        }

    } else {
        holder.getUnSplitLinear().setVisibility(LinearLayout.GONE);

        LinearLayout splitLayout = holder.getSplitLinear();
        splitLayout.removeAllViews();
        LayoutInflater inflater = activity.getLayoutInflater();
        for (Triplet subOp : operation.getSplits()) {
            View view = inflater.inflate(R.layout.split_layout, null);

            TextView category = (TextView) view.findViewById(R.id.splitLayout_category);
            TextView memo = (TextView) view.findViewById(R.id.splitLayout_memo);
            TextView amount = (TextView) view.findViewById(R.id.splitLayout_amount);
            //System.out.println(activity.getString(R.string.cardLayout_category) + " " + (subOp.getCategory().getParent() == null ? "" :subOp.getCategory().getParent().getName() + ": ") + subOp.getCategory().getName());
            category.setText(activity.getString(R.string.Category) + " : "
                    + (subOp.getCategory().getParent() == null ? ""
                            : subOp.getCategory().getParent().getName() + ": ")
                    + subOp.getCategory().getName());
            amount.setText(colorText(activity.getString(R.string.Amount) + " : ",
                    "" + Round.roundAmount(subOp.getAmount())));
            memo.setText(activity.getString(R.string.Category) + " : " + operation.getWording());
            splitLayout.addView(view);
        }
    }
    try {
        holder.getAmount().setText(colorText(activity.getString(R.string.Amount) + " : ",
                String.valueOf(Round.roundAmount(operation.getAmount()))));
    } catch (Exception e) {
    }
    try {
        holder.getBalance().setText(colorText(activity.getString(R.string.Balance) + " : ",
                String.valueOf(Round.roundAmount(operation.getBalanceAccount()))));
    } catch (Exception e) {
    }

    if (operation.isSplit()) {
        holder.getOption().setImageResource(R.drawable.split);
    } else if (operation.isRemind()) {
        holder.getOption().setImageResource(R.drawable.remind);
        holder.getCard().setCardBackgroundColor(Color.parseColor("#ffebee"));
    } else {
        holder.getOption().setImageDrawable(null);
    }

    if (!operation.isReconciled() && !operation.isRemind()) {
        holder.getCard().setCardBackgroundColor(Color.parseColor("#fff3e0"));
    } else if (operation.isReconciled()) {
        holder.getCard().setCardBackgroundColor(Color.parseColor("#ffffff"));
    }

    try {
        switch (operation.getPayMode()) {
        case PayMode.CREDIT_CARD:
            holder.getMode().setImageResource(R.drawable.mastercard);
            break;
        case PayMode.DEBIT_CARD:
            holder.getMode().setImageResource(R.drawable.card);
            break;
        case PayMode.CASH:
            holder.getMode().setImageResource(R.drawable.cash);
            break;
        case PayMode.TRANSFERT:
            holder.getMode().setImageResource(R.drawable.transfert);
            break;
        case PayMode.ELECTRONIC_PAYMENT:
            holder.getMode().setImageResource(R.drawable.nfc);
            break;
        case PayMode.CHEQUE:
            holder.getMode().setImageResource(R.drawable.cheque);
            break;
        default:
            holder.getMode().setImageDrawable(null);
            break;
        }
    } catch (Exception e) {
    }

}