Java Code Examples for android.content.Intent#putExtras()

The following examples show how to use android.content.Intent#putExtras() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchActivity.java    From custom-searchable with Apache License 2.0 6 votes vote down vote up
private void sendSuggestionIntent(ResultItem item) {
    try {
        Intent sendIntent = new Intent(this, Class.forName(searchableActivity));
        sendIntent.setAction(Intent.ACTION_VIEW);
        sendIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

        Bundle b = new Bundle();
        b.putParcelable(CustomSearchableConstants.CLICKED_RESULT_ITEM, item);

        sendIntent.putExtras(b);
        startActivity(sendIntent);
        finish();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: AlarmClock.java    From Moring-Alarm with Apache License 2.0 6 votes vote down vote up
public void turnAlarm(AlarmInfo alarmInfo,String AlarmID,Boolean isOn){
    if(alarmInfo==null){
        Log.d("alarm","传入AlarmInfo不为空");
        alarmInfo=dao.findById(AlarmID);
    }
    this.alarmInfo=alarmInfo;
    AlarmManager mAlamManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    int id=dao.getOnlyId(alarmInfo);
    Intent intent = new Intent(context, AlarmReciver.class);
    Bundle bundle=new Bundle();
    bundle.putSerializable("alarminfo", alarmInfo);
    intent.putExtras(bundle);
    intent.setAction("com.Joe.RING_ALARM");
    intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    intent.putExtra("alarmid", id);
    intent.putExtra("cancel",false);
    intent.putExtra("getid",alarmInfo.getId());
    Log.d("alarm", "id" + id);
    //每个闹钟不同的pi
    PendingIntent pi= PendingIntent.getBroadcast(context,id, intent,PendingIntent.FLAG_UPDATE_CURRENT);
    if(isOn){
        startAlarm(mAlamManager,pi);
    }else{
        cancelAlarm(intent);
    }
}
 
Example 3
Source File: BackendlessFCMService.java    From Android-SDK with MIT License 6 votes vote down vote up
private void handleMessageWithTemplate( final Context context, Intent intent, AndroidPushTemplate androidPushTemplate, final int notificationId )
{
  Bundle newBundle = PushTemplateHelper.prepareMessageBundle( intent.getExtras(), androidPushTemplate, notificationId );

  Intent newMsgIntent = new Intent();
  newMsgIntent.putExtras( newBundle );

  if( !this.onMessage( context, newMsgIntent ) )
    return;

  if( androidPushTemplate.getContentAvailable() != null && androidPushTemplate.getContentAvailable() == 1 )
    return;

  Notification notification = PushTemplateHelper.convertFromTemplate( context, androidPushTemplate, newBundle, notificationId );
  PushTemplateHelper.showNotification( context, notification, androidPushTemplate.getName(), notificationId );
}
 
Example 4
Source File: ActionsReceiver.java    From Androzic with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent)
{
	String action = intent.getAction();
	Log.i(TAG, "Action received: " + action);

	Intent activity = new Intent(context, MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

	if (action.equals("com.androzic.COORDINATES_RECEIVED"))
	{
		activity.putExtras(intent);
		activity.putExtra(MainActivity.SHOW_FRAGMENT, CoordinatesReceived.class);
	}
	if (action.equals("com.androzic.CENTER_ON_COORDINATES"))
	{
		activity.putExtras(intent);
	}
	context.startActivity(activity);
}
 
Example 5
Source File: RxQuickActivity.java    From AndroidQuick with MIT License 5 votes vote down vote up
/**
 * startActivityForResult with bundle
 *
 * @param clazz
 * @param requestCode
 * @param bundle
 */
protected void readyGoForResult(Class<?> clazz, int requestCode, Bundle bundle) {
    Intent intent = new Intent(this, clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
}
 
Example 6
Source File: MainActivity.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
private void launch() {
    Intent intent = new Intent(this, NavigationActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (getIntent().getExtras() != null) {
        intent.putExtras(getIntent().getExtras());
    }
    startActivity(intent);
    finish();
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
 
Example 7
Source File: App.java    From DMusic with Apache License 2.0 5 votes vote down vote up
private static void exit(@NonNull Context context, @NonNull Class<?> cls) {
    Intent intent = new Intent(context, cls);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Bundle bundle = new Bundle();
    bundle.putBoolean(TAG_EXIT, true);
    intent.putExtras(bundle);
    context.startActivity(intent);
}
 
Example 8
Source File: BaseActivity.java    From qvod with MIT License 5 votes vote down vote up
/**
 * [含有Bundle通过Class打开编辑界面]
 *
 * @param cls
 * @param bundle
 * @param requestCode
 */
public void startActivityForResult(Class<?> cls, Bundle bundle,
                                   int requestCode) {
    Intent intent = new Intent();
    intent.setClass(this, cls);
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
}
 
Example 9
Source File: JumpUtils.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
/**
 * 启动视频播放页面
 *
 * @param context
 * @param bundle
 */
public static void startPictureVideoPlayActivity(Context context, Bundle bundle, int requestCode) {
    if (!DoubleUtils.isFastDoubleClick()) {
        Intent intent = new Intent();
        intent.setClass(context, PictureVideoPlayActivity.class);
        intent.putExtras(bundle);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {
            ((Activity) context).startActivityForResult(intent, requestCode);
        }
    }
}
 
Example 10
Source File: BaseFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到activity,并附带bundle
 *
 * @param clazz  Activity
 * @param extras 附带Bundle
 */
protected void openActivity(Class<?> clazz, Bundle extras) {
    Intent intent = new Intent(getActivity(), clazz);
    if (extras != null) {
        intent.putExtras(extras);
    }
    startActivity(intent);
}
 
Example 11
Source File: LeanplumPushReceiver.java    From Leanplum-Android-SDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
  try {
    if (intent == null) {
      Log.e("Received a null intent.");
      return;
    }
    // Parse manifest and pull metadata which contains client broadcast receiver class.
    String receiver = LeanplumManifestHelper.parseNotificationMetadata();
    // If receiver isn't found we will open up notification with default activity
    if (receiver == null) {
      Log.d("Custom broadcast receiver class not set, using default one.");
      LeanplumPushService.openNotification(context, intent);
    } else {
      Log.d("Custom broadcast receiver class found, using it to handle push notifications.");
      // Forward Intent to a client broadcast receiver.
      Intent forwardIntent = new Intent();
      // Add action to be able to differentiate between multiple intents.
      forwardIntent.setAction(LeanplumPushService.LEANPLUM_NOTIFICATION);
      forwardIntent.setClassName(context, receiver);
      forwardIntent.putExtras(intent.getExtras());
      context.sendBroadcast(forwardIntent);
    }
  } catch (Throwable t) {
    Util.handleException(t);
  }
  Leanplum.countAggregator().incrementCount("did_receive_remote_notification");
}
 
Example 12
Source File: DownloadVideoTask.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
protected void onProgressUpdate(Video... values) {
    super.onProgressUpdate(values);
    Intent i = new Intent(Constants.VIDEO_UPDATE_ACTION);
    Bundle bundle = new Bundle();
    bundle.putSerializable(Constants.VIDEO, values[0]);
    i.putExtras(bundle);
    mContext.sendBroadcast(i);
}
 
Example 13
Source File: ShadowSignatureActivity.java    From SSForms with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(this, SignaturePickerActivity.class);
    intent.putExtras(getIntent().getExtras());
    startActivityForResult(intent, RC_SIGANTURE_PICKER);
}
 
Example 14
Source File: ListenerService.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showConfirmationDialog(String title, String message, String actionstring) {

        Intent intent = new Intent(this, AcceptActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle params = new Bundle();
        params.putString("title", title);
        params.putString("message", message);
        params.putString("actionstring", actionstring);
        intent.putExtras(params);
        startActivity(intent);
    }
 
Example 15
Source File: ArmorClickListener.java    From MonsterHunter4UDatabase with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    Intent i = new Intent(c, ArmorDetailActivity.class);
    i.putExtra(ArmorDetailActivity.EXTRA_ARMOR_ID, id);

    // If we are being called by something else
    if (activity != null) {
        i.putExtras(activity.getIntent().getExtras());
        activity.startActivityForResult(i, requestCode);
    }
    else {
        c.startActivity(i);
    }
}
 
Example 16
Source File: ActivityUtil.java    From Meizi with Apache License 2.0 5 votes vote down vote up
public static void startActivityForResult(Activity activity, String action, Bundle bundle, int result) {
    if (!DoubleClickUtil.isFastDoubleClick())
        return;
    Intent intent = new Intent();
    intent.setAction(action);
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    activity.startActivityForResult(intent, result);
}
 
Example 17
Source File: ViewerActivity.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
public static void showImage(@NonNull Context context, @NonNull String title,
                             @NonNull String imageUrl){
    Intent intent = new Intent(context, ViewerActivity.class);
    intent.putExtras(BundleHelper.builder().put("viewerType", ViewerType.Image)
            .put("title", title).put("imageUrl", imageUrl).build());
    context.startActivity(intent);
}
 
Example 18
Source File: EmailService.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Classes wishing to access the email sending functionality should pass an
 * intent constructed with the following action and extras.
 * <p>
 * recipient addresses:
 * Intent.EXTRA_EMAIL, String[]
 * subject:
 * Intent.EXTRA_SUBJECT, String
 * text:
 * Intent.EXTRA_TEXT, CharSequence
 * attachments:
 * Intent.EXTRA_STREAM, List&lt;Uri&gt; or Uri
 */
protected void onHandleIntent(Intent intent) {
    try {
        // TODO Auto-generated method stub
        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("message/rfc822");
        mailer.putExtras(intent);
        mailer.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //TODO Success status?
        startActivity(mailer);
        sendBroadcast(new Intent(SENT));
    } catch (Exception e) {
        sendBroadcast(new Intent(FAILED));
    }
}
 
Example 19
Source File: IntentHelper.java    From Alibaba-Android-Certification with MIT License 4 votes vote down vote up
public static void openClassResult(Context mContext, Class<?> cls,int requestCode,Bundle bundle){
    Intent q=new Intent(mContext,cls);
    q.putExtras(bundle);
    ((Activity)mContext).startActivityForResult(q,requestCode);
}
 
Example 20
Source File: UseActivityInterceptor.java    From android-spock with Apache License 2.0 3 votes vote down vote up
/**
 * The intent to launch the Activity.
 *
 * @param targetPackage The package of the Activity.
 * @param activityClass The Activity class send the intent to.
 * @param bundleCreator Bundle creator instance that will give a bundle to the activity.
 * @param <T> The specific Activity type.
 * @return The intent to start the activity.
 */
protected <T extends Activity> Intent getLaunchIntent(String targetPackage,
    Class<T> activityClass, BundleCreator bundleCreator) {
  Intent intent = new Intent(Intent.ACTION_MAIN);
  intent.setClassName(targetPackage, activityClass.getName());
  intent.putExtras(bundleCreator.createBundle());
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  return intent;
}