android.os.Bundle#isEmpty ( )源码实例Demo

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

源代码1 项目: Saiy-PS   文件: SaiyInteractionService.java
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "onStartCommand: " + startId);
    }

    final Bundle bundle = intent.getExtras();
    if (bundle != null && !bundle.isEmpty()) {

        hotword = bundle.getString(EXTRA_VOICE_KEYPHRASE_HINT_TEXT);
        locale = UtilsLocale.stringToLocale(bundle.getString(EXTRA_VOICE_KEYPHRASE_LOCALE,
                SupportedLanguage.ENGLISH.getLanguageCountry()));

        if (DEBUG) {
            MyLog.i(CLS_NAME, "hotword: " + hotword);
            MyLog.i(CLS_NAME, "locale: " + locale.toString());
        }
    }

    return super.onStartCommand(intent, flags, startId);
}
 
源代码2 项目: gsn   文件: GCMIntentService.java
@Override
protected void onHandleIntent(Intent intent) {
	Bundle extras = intent.getExtras();
	GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

	String messageType = gcm.getMessageType(intent);

	if (!extras.isEmpty()) {
		if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
			sendNotification("Send error: " + extras.toString());
		} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
			sendNotification("Deleted messages on server: "
					+ extras.toString());
		} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

			sendNotification("Message Received from Google GCM Server: "  + extras.get(CommonUtilities.EXTRA_MESSAGE));
			Log.i(TAG, "Received: " + extras.toString());
		}
	}
	GCMBroadcastReceiver.completeWakefulIntent(intent);
}
 
源代码3 项目: PermissionsSample   文件: ContactListFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        contactList = savedInstanceState.getParcelableArrayList(MainActivity.CURRENT_CONTACT_KEY);
    }

    //Here we could use a ServiceLocator or a dependency injector to inject the depenencies.
    // I've decided not to use them since I want that this sample app is really to understand even for
    // beginners.
    ThreadExecutor threadExecutor = JobExecutor.getInstance();
    PostExecutionThread postExecutionThread = UIThread.getInstance();
    ListContactsAction listContactsAction = new ListListContactsActionImpl(this.getContext());
    ListContactsUseCase listContactsUseCase = new ListContactsUseCaseImpl(listContactsAction, threadExecutor,
            postExecutionThread);
    contactListPresenter = new ContactListPresenter(this, listContactsUseCase);
}
 
源代码4 项目: letv   文件: ShareWeiboWebViewClient.java
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (this.mCallBack != null) {
        this.mCallBack.shouldOverrideUrlLoadingCallBack(view, url);
    }
    if (!url.startsWith(WeiboSdkBrowser.BROWSER_CLOSE_SCHEME)) {
        return super.shouldOverrideUrlLoading(view, url);
    }
    Bundle bundle = Utility.parseUri(url);
    if (!(bundle.isEmpty() || this.mListener == null)) {
        this.mListener.onComplete(bundle);
    }
    String errCode = bundle.getString("code");
    String errMsg = bundle.getString("msg");
    if (TextUtils.isEmpty(errCode)) {
        this.mShareRequestParam.sendSdkCancleResponse(this.mAct);
    } else if ("0".equals(errCode)) {
        this.mShareRequestParam.sendSdkOkResponse(this.mAct);
    } else {
        this.mShareRequestParam.sendSdkErrorResponse(this.mAct, errMsg);
    }
    WeiboSdkBrowser.closeBrowser(this.mAct, this.mShareRequestParam.getAuthListenerKey(), null);
    return true;
}
 
/**
 * 캐시로 부터 사용자정보를 읽어온다.
 * @return 캐시에서 읽은 사용자정보
 */
public static UserProfile loadFromCache() {
    SharedPreferencesCache cache = Session.getAppCache();
    if(cache == null)
        return null;

    Bundle bundle = cache.load();

    final long userId = bundle.getLong(CACHE_USER_ID);
    bundle.remove(CACHE_USER_ID);
    final String nickname = bundle.getString(CACHE_NICKNAME);
    bundle.remove(CACHE_NICKNAME);
    final String thumbnailPath = bundle.getString(CACHE_THUMBNAIL_PATH);
    bundle.remove(CACHE_THUMBNAIL_PATH);
    final String profilePath = bundle.getString(CACHE_PROFILE_PATH);
    bundle.remove(CACHE_PROFILE_PATH);

    Map<String, String> properties = new HashMap<String, String>();
    if(!bundle.isEmpty()){
        for(String key : bundle.keySet()){
            if(key.startsWith(CACHE_USER_PREFIX))
                properties.put(key, bundle.getString(key));
        }
    }

    return new UserProfile(userId, nickname, thumbnailPath, profilePath, properties);
}
 
源代码6 项目: weex   文件: DecodeHintManager.java
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
源代码7 项目: Pushjet-Android   文件: GcmIntentService.java
@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
        try {
            JSONObject AzMsg = new JSONObject(extras.getString("message"));
            JSONObject AzServ = AzMsg.getJSONObject("service");
            PushjetService srv = new PushjetService(
                    AzServ.getString("public"),
                    AzServ.getString("name"),
                    new Date((long) AzServ.getInt("created") * 1000)
            );
            srv.setIcon(AzServ.getString("icon"));

            PushjetMessage msg = new PushjetMessage(
                    srv,
                    AzMsg.getString("message"),
                    AzMsg.getString("title"),
                    AzMsg.getInt("timestamp")
            );
            msg.setLevel(AzMsg.getInt("level"));
            msg.setLink(AzMsg.getString("link"));
            DatabaseHandler db = new DatabaseHandler(this);
            db.addMessage(msg);
            sendNotification(msg);
        } catch (JSONException ignore) {
            Log.e("PushjetJson", ignore.getMessage());
        }
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
    sendBroadcast(new Intent("PushjetMessageRefresh"));
}
 
@Override
public void onResults(Bundle bundle) {
  if (bundle.isEmpty()) {
    result = "";
  } else {
    ArrayList<String> results = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    result = results.get(0);
  }
  speechListener.onResult(result);
}
 
源代码9 项目: actor-platform   文件: PushReceiver.java
@Override
public void onReceive(Context context, Intent intent) {
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    Bundle extras = intent.getExtras();
    String messageType = gcm.getMessageType(intent);
    if (!extras.isEmpty()) {
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            ActorSDK.sharedActor().waitForReady();
            if (extras.containsKey("seq")) {
                int seq = Integer.parseInt(extras.getString("seq"));
                int authId = Integer.parseInt(extras.getString("authId", "0"));
                Log.d(TAG, "Push received #" + seq);
                ActorSDK.sharedActor().getMessenger().onPushReceived(seq, authId);
                setResultCode(Activity.RESULT_OK);
            } else if (extras.containsKey("callId")) {
                long callId = Long.parseLong(extras.getString("callId"));
                int attempt = 0;
                if (extras.containsKey("attemptIndex")) {
                    attempt = Integer.parseInt(extras.getString("attemptIndex"));
                }
                Log.d(TAG, "Received Call #" + callId + " (" + attempt + ")");
                ActorSDK.sharedActor().getMessenger().checkCall(callId, attempt);
                setResultCode(Activity.RESULT_OK);
            }
        }
    }
    WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
 
源代码10 项目: Mobilyzer   文件: GcmIntentService.java
@Override
protected void onHandleIntent(Intent intent) {
  Bundle extras = intent.getExtras();
  GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
  // The getMessageType() intent parameter must be the intent you received
  // in your BroadcastReceiver.
  String messageType = gcm.getMessageType(intent);

  if (!extras.isEmpty()) { // has effect of unparcelling Bundle
    /*
     * Filter messages based on message type. Since it is likely that GCM will be extended in the
     * future with new message types, just ignore any message types you're not interested in, or
     * that you don't recognize.
     */
    if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
      Logger.d("GCMManager -> GcmIntentService -> MESSAGE_TYPE_SEND_ERROR");
    } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
      Logger.d("GCMManager -> GcmIntentService -> MESSAGE_TYPE_DELETED");
    } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
      Logger.d("GCMManager -> MESSAGE_TYPE_MESSAGE -> " + extras.toString());
      if (extras.containsKey("task")) {
        Logger.d("GCMManager -> " + extras.getString("task"));
        
        Intent newintent = new Intent();
        newintent.setAction(UpdateIntent.GCM_MEASUREMENT_ACTION);
        newintent.putExtra(UpdateIntent.MEASUREMENT_TASK_PAYLOAD, extras.getString("task"));
        sendBroadcast(newintent);

      }
    }
  }
  // Release the wake lock provided by the WakefulBroadcastReceiver.
  GcmBroadcastReceiver.completeWakefulIntent(intent);
}
 
源代码11 项目: zxingfragmentlib   文件: DecodeHintManager.java
public static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
源代码12 项目: dcs-sdk-java   文件: BaiduDialog.java
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    LogUtil.d(LOG_TAG, "Redirect URL: " + url);
    /*
     * 如果url的地址为bdconnect://success,即使用User-Agent方式获取用户授权的redirct
     * url,则截取url中返回的各种token参数,
     * 如果出错,则通过listener的相应处理方式回调
     */
    if (url.startsWith(BaiduOauthImplicitGrant.SUCCESS_URI)) {
        Bundle values = OauthNetUtil.parseUrl(url);
        if (values != null && !values.isEmpty()) {
            String error = values.getString("error");
            // 用户取消授权返回error=access_denied
            if ("access_denied".equals(error)) {
                mListener.onCancel();
                BaiduDialog.this.dismiss();
                return true;
            }
            // 请求出错时返回error=1100&errorDesp=error_desp
            String errorDesp = values.getString("error_description");
            if (error != null && errorDesp != null) {
                mListener.onBaiduException(new BaiduException(error, errorDesp));
                BaiduDialog.this.dismiss();
                return true;
            }
            mListener.onComplete(values);
            BaiduDialog.this.dismiss();
            return true;
        }
    } else if (url.startsWith(BaiduOauthImplicitGrant.CANCEL_URI)) {
        mListener.onCancel();
        BaiduDialog.this.dismiss();
        return true;
    }
    return false;
}
 
源代码13 项目: CodeScaner   文件: DecodeHintManager.java
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
源代码14 项目: barcodescanner-lib-aar   文件: DecodeHintManager.java
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;
  }
  Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);

  for (DecodeHintType hintType: DecodeHintType.values()) {

    if (hintType == DecodeHintType.CHARACTER_SET ||
        hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK ||
        hintType == DecodeHintType.POSSIBLE_FORMATS) {
      continue; // This hint is specified in another way
    }

    String hintName = hintType.name();
    if (extras.containsKey(hintName)) {
      if (hintType.getValueType().equals(Void.class)) {
        // Void hints are just flags: use the constant specified by the DecodeHintType
        hints.put(hintType, Boolean.TRUE);
      } else {
        Object hintData = extras.get(hintName);
        if (hintType.getValueType().isInstance(hintData)) {
          hints.put(hintType, hintData);
        } else {
          Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData);
        }
      }
    }
  }

  Log.i(TAG, "Hints from the Intent: " + hints);
  return hints;
}
 
源代码15 项目: FastAccess   文件: BaseActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (layout() != 0) {
        setContentView(layout());
        ButterKnife.bind(this);
    }
    Icepick.setDebug(BuildConfig.DEBUG);
    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        Icepick.restoreInstanceState(this, savedInstanceState);
    }
    setupToolbarAndStatusBar();
}
 
源代码16 项目: ZhihuDailyFluxRRD   文件: BundleUtil.java
public static Throwable getThrowable(Bundle bundle) {
    if (bundle == null || bundle.isEmpty()) {
        throw new IllegalArgumentException("the bundle is null or empty");
    }
    return (Throwable) bundle.getSerializable(BundleKey.THROWABLE);
}
 
源代码17 项目: mvvm-template   文件: BaseBottomSheetDialog.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        StateSaver.restoreInstanceState(this, savedInstanceState);
    }
}
 
源代码18 项目: Saiy-PS   文件: UtilsBundle.java
public static boolean notNaked(@Nullable final Bundle bundle) {
    return bundle != null && !bundle.isEmpty();
}
 
源代码19 项目: zulip-android   文件: GcmBroadcastReceiver.java
@Override
public void onReceive(Context context, Intent intent) {
    // handle cancel notification action on uploads
    final String action = intent.getAction();
    if (Constants.CANCEL.equals(action)) {
        int notifId = intent.getIntExtra("id", 0);
        try {
            ZulipApp.get().getZulipActivity().cancelRequest(notifId);
        } catch (NullPointerException e) {
            ZLog.log("onReceive: app destroyed but notification visible");
            return;
        }
    }

    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*
         * Filter messages based on message type. Since it is likely that
         * GCM will be extended in the future with new message types, just
         * ignore any message types you're not interested in, or that you
         * don't recognize.
         */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
                .equals(messageType)) {
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
                .equals(messageType)) {
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
                .equals(messageType)) {

            Log.i(TAG, "Received: " + extras.toString());
            if (extras.getString("event").equals("message")) {
                Intent broadcast = new Intent(getGCMReceiverAction(context.getApplicationContext()));
                broadcast.putExtras(extras);
                context.sendOrderedBroadcast(broadcast, null);
            }
        }
    }

    setResultCode(Activity.RESULT_OK);
}
 
源代码20 项目: android-job   文件: JobRequest.java
/**
 * Set optional transient extras. <b>WARNING:</b> It's not guaranteed that a transient job will
 * run at all, e.g. rebooting the device or force closing the app will cancel the job. This is
 * only helpful for jobs which should start soon and can be cancelled automatically.
 *
 * <br>
 * <br>
 *
 * If the passed in bundle is {@code null} or empty, then the previous extras are reset to the default
 * and the job won't be transient.
 *
 * @param extras  Bundle containing extras you want the scheduler to hold on to for you.
 */
public Builder setTransientExtras(@Nullable Bundle extras) {
    mTransient = extras != null && !extras.isEmpty();
    mTransientExtras = mTransient ? new Bundle(extras) : Bundle.EMPTY;
    return this;
}