本文整理匯總了Java中android.app.PendingIntent.CanceledException類的典型用法代碼示例。如果您正苦於以下問題:Java CanceledException類的具體用法?Java CanceledException怎麽用?Java CanceledException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CanceledException類屬於android.app.PendingIntent包,在下文中一共展示了CanceledException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: launchAppForMessage
import android.app.PendingIntent.CanceledException; //導入依賴的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);
}
}
示例2: forceOpenGPS
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
/**
* 強製打開GPS
*
* @param context
*/
public static void forceOpenGPS(Context context) {
// 4.0++
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
context.sendBroadcast(intent);
String provider = Settings.Secure.getString(
context.getContentResolver(),
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if (!provider.contains("gps")) { // if gps is disabled
final Intent poke = new Intent();
poke.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
context.sendBroadcast(poke);
}
} else {
Intent GPSIntent = new Intent();
GPSIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
GPSIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
} catch (CanceledException e) {
}
}
}
示例3: handleAuthorizationComplete
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
private void handleAuthorizationComplete() {
Uri responseUri = getIntent().getData();
Intent responseData = extractResponseData(responseUri);
if (responseData == null) {
Logger.error("Failed to extract OAuth2 response from redirect");
return;
}
responseData.setData(responseUri);
if (mCompleteIntent != null) {
Logger.debug("Authorization complete - invoking completion intent");
try {
mCompleteIntent.send(this, 0, responseData);
} catch (CanceledException ex) {
Logger.error("Failed to send completion intent", ex);
}
} else {
setResult(RESULT_OK, responseData);
}
}
示例4: handleAuthorizationCanceled
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
private void handleAuthorizationCanceled() {
Logger.debug("Authorization flow canceled by user");
Intent cancelData = AuthorizationException.fromTemplate(
AuthorizationException.GeneralErrors.USER_CANCELED_AUTH_FLOW,
null)
.toIntent();
if (mCancelIntent != null) {
try {
mCancelIntent.send(this, 0, cancelData);
} catch (CanceledException ex) {
Logger.error("Failed to send cancel intent", ex);
}
} else {
setResult(RESULT_CANCELED, cancelData);
Logger.debug("No cancel intent set - will return to previous activity");
}
}
示例5: openGps
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
/**
* 強製幫用戶打開GPS
* @param context
*/
@SuppressLint("InlinedApi")
public static void openGps(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Settings.System.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
} else {
Intent i = new Intent();
i.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
i.addCategory("android.intent.category.ALTERNATIVE");
i.setData(Uri.parse("custom:3"));
try{
PendingIntent.getBroadcast(context, 0, i, 0).send();
} catch(CanceledException e) {
e.printStackTrace();
}
}
}
示例6: onPositiveGaiaRecoveryDialogResponse
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
public static void onPositiveGaiaRecoveryDialogResponse()
{
PendingIntent localPendingIntent = getRecoveryIntentIfExists();
if (localPendingIntent == null)
{
FinskyLog.wtf("Called Gaia recovery flow but PendingIntent didn't exist.", new Object[0]);
return;
}
try
{
localPendingIntent.send();
return;
}
catch (PendingIntent.CanceledException localCanceledException)
{
FinskyLog.e(localCanceledException, "PendingIntent for GAIA auth was canceled", new Object[0]);
return;
}
finally
{
sGaiaAuthIntent = null;
}
}
示例7: startPurchaseIntent
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
/**
* Starts the specified purchase intent with the specified activity.
*
* @param activity
* @param purchaseIntent
* purchase intent.
* @param intent
*/
public static void startPurchaseIntent(Activity activity, PendingIntent purchaseIntent, Intent intent) {
if (Compatibility.isStartIntentSenderSupported()) {
// This is on Android 2.0 and beyond. The in-app buy page activity
// must be on the activity stack of the application.
Compatibility.startIntentSender(activity, purchaseIntent.getIntentSender(), intent);
} else {
// This is on Android version 1.6. The in-app buy page activity must
// be on its own separate activity stack instead of on the activity
// stack of the application.
try {
purchaseIntent.send(activity, 0 /* code */, intent);
} catch (CanceledException e) {
Log.e(LOG_TAG, "Error starting purchase intent", e);
}
}
}
示例8: onSingleTapUp
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public boolean onSingleTapUp(MotionEvent e) {
if(mIntent != null) {
try {
mIntent.send();
ControlService service = (ControlService) ControlService.getInstance();
if(service != null && service.isAttachedToWindow() && ControlService.isRunning()) {
service.close();
}
if(mDismissOnClick && mDismissable && !mOngoing) {
removeNotification(mPkg, mTag, mId);
}
} catch (CanceledException ex) {
}
}
return false;
}
示例9: clickMenuItemWithUrl
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
/**
* Triggers the client-defined action when the user clicks a custom menu item.
* @param menuIndex The index that the menu item is shown in the result of
* {@link #getMenuTitles()}
*/
public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) {
Intent addedIntent = new Intent();
addedIntent.setData(Uri.parse(url));
try {
// Media viewers pass in PendingIntents that contain CHOOSER Intents. Setting the data
// in these cases prevents the Intent from firing correctly.
String title = mMenuEntries.get(menuIndex).first;
PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second;
pendingIntent.send(
activity, 0, isMediaViewer() ? null : addedIntent, mOnFinished, null);
if (shouldEnableEmbeddedMediaExperience()
&& TextUtils.equals(
title, activity.getString(R.string.download_manager_open_with))) {
RecordUserAction.record("CustomTabsMenuCustomMenuItem.DownloadsUI.OpenWith");
}
} catch (CanceledException e) {
Log.e(TAG, "Custom tab in Chrome failed to send pending intent.");
}
}
示例10: run
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public void run() {
if(password.length() > 4) {
password = password.substring(0, 4);
}
if(password.length() == 4) {
if(TextUtils.equals(MD5Utils.MD5(password), config.getDigitalPassword())) {
if(isLaunchCamera) {
AppUtils.launchCamera(getContext());
} else if(notification != null) {
try {
notification.contentIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
LockerManager.getInstance(getContext()).unlock();
} else {
indicator.passwordWrong();
password = "";
}
}
}
示例11: onPatternDetected
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public void onPatternDetected(List<Cell> pattern) {
if (pattern == null) {
return;
}
if (TextUtils.equals(MD5Utils.MD5(LockPatternUtils.patternToString(pattern)), config.getPatternPassword())) {
if(isLaunchCamera) {
AppUtils.launchCamera(getContext());
} else if(notification != null) {
try {
notification.contentIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
mPatternView.setDisplayMode(LockPicturePatternView.DisplayMode.Right);
LockerManager.getInstance(getContext()).onUnlock();
mPatternView.post(mClearPatternRunnable);
} else {
mPatternView.setDisplayMode(LockPicturePatternView.DisplayMode.Wrong);
mPatternView.postDelayed(mClearPatternRunnable, 1000);
mTVDrawPattern.setText(R.string.password_wrong);
YoYo.with(Techniques.Shake).duration(1000).playOn(mTVDrawPattern);
}
}
示例12: onPatternDetected
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public void onPatternDetected(List<Cell> pattern) {
if (pattern == null) {
return;
}
if (TextUtils.equals(MD5Utils.MD5(LockPatternUtils.patternToString(pattern)), config.getPatternPassword())) {
if(isLaunchCamera) {
AppUtils.launchCamera(getContext());
} else if(notification != null) {
try {
notification.contentIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
mPatternView.setDisplayMode(LockCPicturePatternView.DisplayMode.Right);
LockerManager.getInstance(getContext()).onUnlock();
mPatternView.post(mClearPatternRunnable);
} else {
mPatternView.setDisplayMode(LockCPicturePatternView.DisplayMode.Wrong);
mPatternView.postDelayed(mClearPatternRunnable, 1000);
mTVDrawPattern.setText(R.string.password_wrong);
YoYo.with(Techniques.Shake).duration(1000).playOn(mTVDrawPattern);
}
}
示例13: onPatternDetected
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public void onPatternDetected(List<Cell> pattern) {
if (pattern == null) {
return;
}
if (TextUtils.equals(MD5Utils.MD5(LockPatternUtils.patternToString(pattern)), config.getPatternPassword())) {
if(isLaunchCamera) {
AppUtils.launchCamera(getContext());
} else if(notification != null) {
try {
notification.contentIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
mPatternView.setDisplayMode(LockPatternView.DisplayMode.Right);
LockerManager.getInstance(getContext()).onUnlock();
mPatternView.post(mClearPatternRunnable);
} else {
mPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
mPatternView.postDelayed(mClearPatternRunnable, 1000);
mTVDrawPattern.setText(R.string.password_wrong);
YoYo.with(Techniques.Shake).duration(1000).playOn(mTVDrawPattern);
}
}
示例14: openNotify
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
/**
* ��֪ͨ����Ϣ
*/
private void openNotify(AccessibilityEvent event){
if (event.getParcelableData() == null || !(event.getParcelableData() instanceof Notification)) {
return;
}
// ���ŵ�֪ͨ����Ϣ��
// ��ȡNotification����
Notification notification = (Notification) event.getParcelableData();
// �������е�PendingIntent�����Ž���
PendingIntent pendingIntent = notification.contentIntent;
try {
pendingIntent.send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
示例15: onCreate
import android.app.PendingIntent.CanceledException; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DashClockExtensionClient<?> client = DashClockExtensionClient.getInstance();
IModel model = client.getCurrent();
if (model != null) {
boolean sent = false;
PendingIntent contentIntent = model.contentIntent();
if (contentIntent != null) {
try {
contentIntent.send();
sent = true;
} catch (CanceledException e) {
// pending intent has been cancelled, try launcher intent
}
}
if (!sent) {
startLauncherActivity(model);
}
}
finish();
}