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

The following examples show how to use android.content.Intent#putExtra() . 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: PoemBuilderActivity.java    From cannonball-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getBooleanExtra(App.BROADCAST_POEM_CREATION_RESULT, false)) {
        Crashlytics.log("PoemBuilder: poem saved, receiver called");
        Toast.makeText(getApplicationContext(),
                getResources().getString(R.string.toast_poem_created), Toast.LENGTH_SHORT)
                .show();
        final Intent i = new Intent(getApplicationContext(), PoemHistoryActivity.class);
        i.putExtra(ThemeChooserActivity.IS_NEW_POEM, true);
        startActivity(i);
    } else {
        Crashlytics.log("PoemBuilder: error when saving poem");
        Toast.makeText(getApplicationContext(),
                getResources().getString(R.string.toast_poem_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }
}
 
Example 2
Source File: TakeVideoActivity.java    From MultiMediaSample with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0x123 && resultCode == RESULT_OK) {
        hasResult = true;
        Intent intent = new Intent();
        intent.putExtra("fileCachePath", fileCachePath);
        setResult(RESULT_OK, intent);
        new File(fileCachePath).delete();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                finish();
            }
        }, 250);
    }
}
 
Example 3
Source File: ShareBroadcastReceiver.java    From Hews with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String url = intent.getDataString();

    if (url != null) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, url);

        Intent chooserIntent = Intent.createChooser(shareIntent, "Share url");
        chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        context.startActivity(chooserIntent);
    }
}
 
Example 4
Source File: PjSipBroadcastEmiter.java    From react-native-sip with GNU General Public License v3.0 5 votes vote down vote up
public void fireIntentHandled(Intent original, Exception e) {
    Intent intent = new Intent();
    intent.setAction(PjActions.EVENT_HANDLED);
    intent.putExtra("callback_id", original.getIntExtra("callback_id", -1));
    intent.putExtra("exception", e.getMessage());

    context.sendBroadcast(intent);
}
 
Example 5
Source File: AgentWebUtils.java    From AgentWeb with Apache License 2.0 5 votes vote down vote up
static Intent getIntentCaptureCompat(Context context, File file) {
	Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
	Uri mUri = getUriFromFile(context, file);
	mIntent.addCategory(Intent.CATEGORY_DEFAULT);
	mIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUri);
	return mIntent;
}
 
Example 6
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent = new Intent();
    if ("friend".equals(chatType)) {
        //跳转到好友个人资料页面
        intent.setClass(ChatActivity.this, UserProfileActivity.class);
    } else {
        //跳转到群组资料页面
        intent.setClass(ChatActivity.this, GroupProfileActivity.class);
    }
    intent.putExtra("id", chatId);
    startActivity(intent);
    return super.onOptionsItemSelected(item);
}
 
Example 7
Source File: StartActivity.java    From EverMemo with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case R.id.settiing:
		Intent intent = new Intent(mContext, SettingActivity.class);
		startActivity(intent);
		break;
	case R.id.sync:
		if (mEvernote.isLogin() == false) {
			mEvernote.auth();
		} else {
			mEvernote.sync(true, true, new SyncHandler());
		}
		break;
	case R.id.feedback:
		Intent Email = new Intent(Intent.ACTION_SEND);
		Email.setType("text/email");
		Email.putExtra(Intent.EXTRA_EMAIL,
				new String[] { getString(R.string.team_email) });
		Email.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback));
		Email.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_title));
		startActivity(Intent.createChooser(Email,
				getString(R.string.email_chooser)));
		break;
	default:
		break;
	}
	return false;
}
 
Example 8
Source File: FileOperations.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
public void restoreAccess(Context context, String filePath) {
    if (context != null) {
        boolean rootIsAvailable = new PrefManager(context).getBoolPref("rootIsAvailable");

        if (!rootIsAvailable) {
            return;
        }

        IntentFilter intentFilterBckgIntSer = new IntentFilter(RootExecService.COMMAND_RESULT);
        LocalBroadcastManager.getInstance(context).registerReceiver(br, intentFilterBckgIntSer);

        String appUID = new PrefManager(context).getStrPref("appUID");
        PathVars pathVars = PathVars.getInstance(context);
        String[] commands = {
                pathVars.getBusyboxPath()+ "chown -R " + appUID + "." + appUID + " " + filePath + " 2> /dev/null",
                "restorecon " + filePath + " 2> /dev/null",
                pathVars.getBusyboxPath() + "sleep 1 2> /dev/null"
        };
        RootCommands rootCommands = new RootCommands(commands);
        Intent intent = new Intent(context, RootExecService.class);
        intent.setAction(RootExecService.RUN_COMMAND);
        intent.putExtra("Commands", rootCommands);
        intent.putExtra("Mark", RootExecService.FileOperationsMark);
        RootExecService.performAction(context, intent);

        waitRestoreAccessWithRoot();
    }
}
 
Example 9
Source File: GalleryActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
void startPhotoTaker() {

        int permissionCheck = ContextCompat.checkSelfPermission(this,
                Manifest.permission.CAMERA);

        if (permissionCheck ==PackageManager.PERMISSION_DENIED)
        {
            // Should we show an explanation?
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.CAMERA)) {

                View view = findViewById(R.id.gallery_fragment);

                // Show an expanation to the user *asynchronously* -- don't block
                // this thread waiting for the user's response! After the user
                // sees the explanation, try again to request the permission.
                Snackbar.make(view, R.string.grant_perms, Snackbar.LENGTH_LONG).show();
            } else {

                // No explanation needed, we can request the permission.

                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA},
                        MY_PERMISSIONS_REQUEST_CAMERA);

                // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
                // app-defined int constant. The callback method gets the
                // result of the request.
            }
        }
        else {

            Intent intent = new Intent(this, CameraActivity.class);
            intent.putExtra(CameraActivity.SETTING_ONE_AND_DONE,false);
            startActivityForResult(intent, ConversationDetailActivity.REQUEST_TAKE_PICTURE);
        }
    }
 
Example 10
Source File: UiUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static void luanchUserItems(Activity activity, User user, int type) {
    Intent intent = new Intent(activity, UserItemsActivity.class);
    intent.putExtra(UiUtils.ARG_USER, user);
    intent.putExtra(UiUtils.ARG_TYPE, type);
    activity.startActivity(intent);

}
 
Example 11
Source File: AlarmReceiverLife.java    From find3-android-scanner with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Log.v(TAG, "Recurring alarm");

    // get data
    String familyName = intent.getStringExtra("familyName");
    String deviceName = intent.getStringExtra("deviceName");
    String locationName = intent.getStringExtra("locationName");
    String serverAddress = intent.getStringExtra("serverAddress");
    boolean allowGPS = intent.getBooleanExtra("allowGPS",false);
    Log.d(TAG,"familyName: "+ familyName);

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
            PowerManager.ACQUIRE_CAUSES_WAKEUP |
            PowerManager.ON_AFTER_RELEASE, "WakeLock");
    wakeLock.acquire();
    Intent scanService = new Intent(context, ScanService.class);
    scanService.putExtra("familyName",familyName);
    scanService.putExtra("deviceName",deviceName);
    scanService.putExtra("locationName",locationName);
    scanService.putExtra("serverAddress",serverAddress);
    scanService.putExtra("allowGPS",allowGPS);
    try {
        context.startService(scanService);
    } catch (Exception e) {
        Log.w(TAG,e.toString());
    }
    Log.d(TAG,"Releasing wakelock");
    if (wakeLock != null) wakeLock.release();
    wakeLock = null;
}
 
Example 12
Source File: Preferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new Preferences activity showing the desired fragment.
 *
 * @param fragmentClass The Class of the fragment to show.
 * @param args Arguments to pass to Fragment.instantiate(), or null.
 */
public void startFragment(String fragmentClass, Bundle args) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClass(this, getClass());
    intent.putExtra(EXTRA_SHOW_FRAGMENT, fragmentClass);
    intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
    startActivity(intent);
}
 
Example 13
Source File: LoginActivity.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
public static void startActivityForAOP(Context context,
                                       String email) {
    Intent intent = new Intent(context, LoginActivity.class);
    if (!TextUtils.isEmpty(email)) {
        intent.putExtra(TyConfig.EMAIL, email);
    }

    intent.putExtra(FROM, AOP);

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    context.startActivity(intent);
}
 
Example 14
Source File: MainActivity.java    From GankMeizhi with Apache License 2.0 5 votes vote down vote up
private void startViewerActivity(View itemView, int position) {
    Intent intent = new Intent(MainActivity.this, ViewerActivity.class);
    intent.putExtra("index", position);

    ActivityOptionsCompat options = ActivityOptionsCompat
            .makeSceneTransitionAnimation(this, itemView, adapter.get(position).url);

    startActivity(intent, options.toBundle());
}
 
Example 15
Source File: ComprehensionTest.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected Intent getActivityIntent() {
    Context targetContext = getInstrumentation()
            .getTargetContext();
    Intent result = new Intent(targetContext, TemplateEditor.class);
    result.putExtra(Constants.TEMPLATE_ID, 5);
    return result;
}
 
Example 16
Source File: ConversationFragment.java    From catnut with MIT License 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
	Cursor c = (Cursor) mAdapter.getItem(position);
	String status = c.getString(c.getColumnIndex(Comment.status));
	Intent intent = new Intent(getActivity(), TweetActivity.class);
	intent.putExtra(Constants.JSON, status);
	startActivity(intent);
}
 
Example 17
Source File: NavigationUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
public static void goToGenre(@NonNull final Activity activity, final Genre genre, @Nullable Pair... sharedElements) {
    final Intent intent = new Intent(activity, GenreDetailActivity.class);
    intent.putExtra(GenreDetailActivity.EXTRA_GENRE, genre);

    activity.startActivity(intent);
}
 
Example 18
Source File: LiveSubTypeActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void launch(Context context, int pageIndex) {
    Intent mIntent = new Intent(context, LiveSubTypeActivity.class);
    mIntent.putExtra(INTENT_KEY_PAGEINDEX, pageIndex);
    context.startActivity(mIntent);
}
 
Example 19
Source File: LocalOAuth2Main.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
/**
 * リクエストデータを使ってアクセストークン発行承認確認画面を起動する.
 * @param request リクエストデータ
 */
public void startConfirmAuthActivity(final ConfirmAuthRequest request) {
    if (request == null) {
        return;
    }

    android.content.Context context = request.getConfirmAuthParams().getContext();
    String[] displayScopes = request.getDisplayScopes();
    ConfirmAuthParams params = request.getConfirmAuthParams();
    
    // Activity起動(許可・拒否の結果は、ApprovalHandlerへ送られる)
    // 詳細ボタン押下時のIntent
    Intent detailIntent = new Intent();
    putExtras(context, request, displayScopes, detailIntent);
    detailIntent.setClass(params.getContext(), ConfirmAuthActivity.class);
    detailIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

    // 許可ボタン押下時のIntent
    Intent acceptIntent = new Intent();
    putExtras(context, request, displayScopes, acceptIntent);
    acceptIntent.setAction(ACTION_OAUTH_ACCEPT);
    acceptIntent.putExtra(EXTRA_APPROVAL, true);

    // 拒否ボタン押下時のIntent
    Intent declineIntent = new Intent();
    putExtras(context, request, displayScopes, declineIntent);
    declineIntent.setAction(ACTION_OAUTH_DECLINE);
    declineIntent.putExtra(EXTRA_APPROVAL, false);

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
        context.startActivity(detailIntent);

        request.startTimer(new ConfirmAuthRequest.OnTimeoutCallback() {
            @Override
            public void onTimeout() {
                processApproval(request.getThreadId(), false);
            }
        });
    } else {
        //許可するボタン押下時のAction
        Notification.Action acceptAction = new Notification.Action.Builder(null,
                ACCEPT_BUTTON_TITLE,
                PendingIntent.getBroadcast(context, 1, acceptIntent, PendingIntent.FLAG_UPDATE_CURRENT)).build();

        //拒否するボタン押下時のAction
        Notification.Action declineAction = new Notification.Action.Builder(null,
                DECLINE_BUTTON_TITLE,
                PendingIntent.getBroadcast(context, 2, declineIntent, PendingIntent.FLAG_UPDATE_CURRENT)).build();

        //詳細を表示ボタン押下時のAction
        Notification.Action detailAction = new Notification.Action.Builder(null,
                DETAIL_BUTTON_TITLE,
                PendingIntent.getActivity(context, 3, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT)).build();

        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("使用するプロファイル:");
        for (String i : displayScopes) {
            stringBuilder.append(i);
            stringBuilder.append(", ");
        }
        stringBuilder.setLength(stringBuilder.length() - 2);

        NotificationUtils.createNotificationChannel(context);
        NotificationUtils.notify(context, NOTIFICATION_ID, stringBuilder.toString(), acceptAction, declineAction, detailAction);
    }
}
 
Example 20
Source File: WASenderAccSvc.java    From WhatsApp-Bulk-Sender with MIT License 4 votes vote down vote up
private void sendNext() {
    Intent intent = new Intent(this, WASenderFgSvc.class);
    intent.putExtra("start", false);
    startService(intent);
}