本文整理汇总了Java中android.content.Intent.addFlags方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.addFlags方法的具体用法?Java Intent.addFlags怎么用?Java Intent.addFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.addFlags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Intent intent2 = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent2,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(context)
.setAutoCancel(true) //Automatically delete the notification
.setSmallIcon(R.drawable.water_bottle_flat) //Notification icon
.setContentIntent(pendingIntent)
.setContentTitle("Time to hydrate")
.setContentText("Drink a glass of water now")
.setCategory(Notification.CATEGORY_REMINDER)
.setPriority(Notification.PRIORITY_HIGH)
.setSound(defaultSoundUri);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(0, notificationBuilder.build());
Toast.makeText(context, "Repeating Alarm Received", Toast.LENGTH_SHORT).show();
}
示例2: launchAppForMessage
import android.content.Intent; //导入方法依赖的package包/类
public void launchAppForMessage(Message message, AppLaunchMethod launchedFrom) {
App app = getAppById(message.getAppId());
PendingIntent pendingIntent = message.getPendingIntent();
if (pendingIntent != null) {
try {
pendingIntent.send();
return;
} catch (CanceledException e) {
Log.d(TAG, "Failed to launch pending intent because it was cancelled");
}
}
Intent launchIntent = app.getLaunchIntentForMessage(message);
if (launchIntent != null) {
launchIntent.addFlags(268435456);
safeStartActivity(launchIntent);
}
}
示例3: openResult
import android.content.Intent; //导入方法依赖的package包/类
private void openResult() {
String path = mEditOutPath.getText().toString();
if (!path.isEmpty()) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
File file = new File(path);
Uri url = FileProvider.getUriForFile(getContext(),
getContext().getPackageName() + ".fileprovider", file);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(url, "text/plain");
Intent chooser = Intent.createChooser(intent, "Choose an application to open with:");
startActivity(chooser);
} catch (Exception e) {
Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
示例4: onOptionsItemSelected
import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_logout) {
sharedPref.setUserId("");
sharedPref.setLoginStatus(false);
sharedPref.setUserRollno("");
sharedPref.setUserEmail("");
sharedPref.setUserPicUrl("");
sharedPref.setUserName("");
LoginManager.getInstance().logOut();
Intent intent = new Intent(MainActivity.this,LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
示例5: startTake
import android.content.Intent; //导入方法依赖的package包/类
private void startTake() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//判断是否有相机应用
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
//创建临时图片文件
File photoFile = null;
try {
photoFile = PictureUtils.createPublicImageFile();
mPublicPhotoPath = photoFile.getAbsolutePath();
} catch (IOException e) {
e.printStackTrace();
}
//设置Action为拍照
if (photoFile != null) {
takePictureIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
//这里加入flag
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri photoURI = FileProvider.getUriForFile(this, "applicationId.fileprovider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQ_GALLERY);
}
}
}
示例6: addShortcutToWebmail
import android.content.Intent; //导入方法依赖的package包/类
public static void addShortcutToWebmail(Context context) {
//Adding shortcut for MainActivity
//on Home screen
Intent shortcutIntent = new Intent(context, WebmailActivity.class);
shortcutIntent.putExtra(Common.WEBVIEW_EXTRA_COLOR, Color.parseColor("#607d8b"));
shortcutIntent.putExtra(Common.WEBVIEW_EXTRA_NAME, context.getString(R.string.title_webapp_email));
shortcutIntent.putExtra(Common.WEBVIEW_EXTRA_URL, WebApps.Webmail);
shortcutIntent.putExtra(Common.WEBVIEW_EXTRA_NLOGIN, true);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "eMailUA");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context,
R.drawable.ic_webmail));
addIntent
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra("duplicate", false); //may be already there so don't duplicate
context.sendBroadcast(addIntent);
}
示例7: InstallServiceQuiet
import android.content.Intent; //导入方法依赖的package包/类
protected static boolean InstallServiceQuiet(Context context)
{
boolean result = true;
try
{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
catch(Exception e)
{
result = false;
}
return result;
}
示例8: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
long completeDownloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if (completeDownloadId == downloadId) {
if (getStatusById(downloadManager, downloadId, DownloadManager.COLUMN_STATUS)
== DownloadManager.STATUS_SUCCESSFUL) {
Toast.makeText(context, "新版本已下载成功", Toast.LENGTH_SHORT).show();
Uri downloadUri = downloadManager.getUriForDownloadedFile(downloadId);
if (downloadUri != null) {
Intent install = new Intent(Intent.ACTION_VIEW);
install.setDataAndType(downloadUri, "application/vnd.android.package-archive");
install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(install);
} else {
Toast.makeText(context, "下载失败", Toast.LENGTH_SHORT).show();
}
}
}
}
示例9: sendLogcat
import android.content.Intent; //导入方法依赖的package包/类
/**
* Send Logcat output via email
*/
private void sendLogcat() {
final File cacheDir = getExternalCacheDir();
if (cacheDir == null) {
Log.i(TAG, "Unable to save Logcat. Shared storage is unavailable!");
return;
}
final File file = new File(cacheDir, "idledaddy-logcat.txt");
try {
Utils.saveLogcat(file);
} catch (IOException e) {
e.printStackTrace();
}
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Idle Daddy Logcat");
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this,
getApplicationContext().getPackageName() + ".provider", file));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
示例10: start
import android.content.Intent; //导入方法依赖的package包/类
public static <T extends BaseActivity> void start(Context ctx,Class<T> c){
if (ctx == null) {
return;
}
Intent intent = new Intent(ctx,c);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(intent);
}
示例11: exit
import android.content.Intent; //导入方法依赖的package包/类
private void exit() {
final Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
hideLock();
}
示例12: goToActivityClearAllStack
import android.content.Intent; //导入方法依赖的package包/类
public void goToActivityClearAllStack(Class c, Bundle bundle){
Intent i = new Intent(this, c);
if (bundle != null) {
i.putExtras(bundle);
}
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);
finish();
}
示例13: share9PicsToWXCircle
import android.content.Intent; //导入方法依赖的package包/类
/**
* 分享9图到朋友圈
*
* @param context
* @param Kdescription 9图上边输入框中的文案
* @param paths 本地图片的路径
*/
public static boolean share9PicsToWXCircle(Context context, String Kdescription, List<String> paths) {
if (!isInstallWeChart(context)) {
ToastUtils.showShortToast("您没有安装微信");
return false;
}
Intent intent = new Intent();
intent.setComponent(new ComponentName(tencentPk, "com.tencent.mm.ui.tools.ShareToTimeLineUI"));
intent.setAction(tencentAction);
ArrayList<Uri> imageList = new ArrayList<>();
for (String picPath : paths) {
File f = new File(picPath);
if (f.exists()) {
// url = MediaStore.Images.Media.insertImage(context.getContentResolver(), picPath, "12312", "你对图片的描述");
Uri imageUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
imageUri = Uri.parse(insertImageToSystem(context, picPath));
} else {
imageUri = Uri.fromFile(f);
}
imageList.add(imageUri);
}
}
if (imageList.size() == 0) {
ToastUtils.showShortToast("文件不存在");
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //添加这一句表示对目标应用临时授权该Uri所代表的文件
}
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, imageList); //图片数据(支持本地图片的Uri形式)
intent.putExtra("Kdescription", Kdescription); //微信分享页面,图片上边的描述、
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(intent);
return true;
}
示例14: startForeground
import android.content.Intent; //导入方法依赖的package包/类
static void startForeground(Context context) {
try {
Intent intent = new Intent(context, OnePxActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
Log.e(TAG, "e:", e);
}
}
示例15: NovaLauncher
import android.content.Intent; //导入方法依赖的package包/类
private void NovaLauncher() {
Intent intent = new Intent("com.teslacoilsw.launcher.APPLY_ICON_THEME");
intent.setPackage("com.teslacoilsw.launcher");
intent.putExtra("com.teslacoilsw.launcher.extra.ICON_THEME_TYPE", "GO");
intent.putExtra("com.teslacoilsw.launcher.extra.ICON_THEME_PACKAGE", BuildConfig.APPLICATION_ID);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
openActivity(intent);
}