android.content.Intent#putExtras ( )源码实例Demo

下面列出了android.content.Intent#putExtras ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: custom-searchable   文件: SearchActivity.java
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();
    }
}
 
源代码2 项目: Moring-Alarm   文件: AlarmClock.java
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);
    }
}
 
源代码3 项目: Androzic   文件: ActionsReceiver.java
@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);
}
 
源代码4 项目: Android-SDK   文件: BackendlessFCMService.java
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 );
}
 
源代码5 项目: SSForms   文件: ShadowSignatureActivity.java
@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);
}
 
源代码6 项目: sana.mobile   文件: EmailService.java
/**
 * 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));
    }
}
 
源代码7 项目: OpenHub   文件: ViewerActivity.java
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);
}
 
源代码8 项目: Meizi   文件: ActivityUtil.java
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);
}
 
@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);
    }
}
 
源代码10 项目: AndroidAPS   文件: ListenerService.java
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);
    }
 
源代码11 项目: AndroidQuick   文件: RxQuickActivity.java
/**
 * 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);
}
 
源代码12 项目: Amphitheatre   文件: DownloadVideoTask.java
@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);
}
 
@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");
}
 
源代码14 项目: BmapLite   文件: BaseFragment.java
/**
 * 跳转到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);
}
 
源代码15 项目: PictureSelector   文件: JumpUtils.java
/**
 * 启动视频播放页面
 *
 * @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);
        }
    }
}
 
源代码16 项目: qvod   文件: BaseActivity.java
/**
 * [含有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);
}
 
源代码17 项目: DMusic   文件: App.java
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);
}
 
源代码18 项目: MTweaks-KernelAdiutorMOD   文件: MainActivity.java
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);
}
 
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);
}
 
源代码20 项目: android-spock   文件: UseActivityInterceptor.java
/**
 * 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;
}
 
 方法所在类
 同类方法