List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferService.java
@Override @SuppressWarnings("checkstyle:hiddenfield") public int onStartCommand(Intent intent, int flags, int startId) { this.startId = startId; if (intent == null) { return START_REDELIVER_INTENT; }/*from w w w. j a v a2 s. c om*/ final String keyForS3Client = intent.getStringExtra(INTENT_BUNDLE_S3_REFERENCE_KEY); s3 = S3ClientReference.get(keyForS3Client); if (s3 == null) { LOGGER.warn("TransferService can't get s3 client, and it will stop."); stopSelf(startId); return START_NOT_STICKY; } updateHandler.sendMessage(updateHandler.obtainMessage(MSG_EXEC, intent)); if (isFirst) { registerReceiver(networkInfoReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); isFirst = false; } /* * The service will not restart if it's killed by system. */ return START_NOT_STICKY; }
From source file:com.cellbots.eyes.EyesActivity.java
/** Called when the activity is first created. */ @Override/* ww w . j a va 2 s . c om*/ public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.eyes_main); mPreview = (SurfaceView) findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; this.registerReceiver(mReceiver, new IntentFilter(EyesActivity.EYES_COMMAND)); mFrame = (FrameLayout) findViewById(R.id.eyes_frame); mWebView = new WebView(this); mWebView.getSettings().setJavaScriptEnabled(true); // Use this if you want to load content locally // mWebView.loadUrl("content://com.cellbot.localpersonas/default/index.html"); mWebView.loadUrl("http://personabots.appspot.com/expressions/tuby"); mFrame.addView(mWebView); }
From source file:cn.hbm.superwechat.DemoHXSDKHelper.java
/** * ?/*from w w w . ja v a 2s .c o m*/ * ?UI???UI??????? * activityList.size() <= 0 ????????Activity Stack */ protected void initEventListener() { eventListener = new EMEventListener() { private BroadcastReceiver broadCastReceiver = null; @Override public void onEvent(EMNotifierEvent event) { EMMessage message = null; if (event.getData() instanceof EMMessage) { message = (EMMessage) event.getData(); EMLog.d(TAG, "receive the event : " + event.getEvent() + ",id : " + message.getMsgId()); } switch (event.getEvent()) { case EventNewMessage: //????UI,???? if (activityList.size() <= 0) { HXSDKHelper.getInstance().getNotifier().onNewMsg(message); } break; case EventOfflineMessage: if (activityList.size() <= 0) { EMLog.d(TAG, "received offline messages"); List<EMMessage> messages = (List<EMMessage>) event.getData(); HXSDKHelper.getInstance().getNotifier().onNewMesg(messages); } break; // below is just giving a example to show a cmd toast, the app should not follow this // so be careful of this case EventNewCMDMessage: { EMLog.d(TAG, "??"); //??body CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody(); final String action = cmdMsgBody.action;//?action //? ? //message.getStringAttribute(""); EMLog.d(TAG, String.format("??action:%s,message:%s", action, message.toString())); final String str = appContext.getString(R.string.receive_the_passthrough); final String CMD_TOAST_BROADCAST = "easemob.demo.cmd.toast"; IntentFilter cmdFilter = new IntentFilter(CMD_TOAST_BROADCAST); if (broadCastReceiver == null) { broadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(appContext, intent.getStringExtra("cmd_value"), Toast.LENGTH_SHORT) .show(); } }; // appContext.registerReceiver(broadCastReceiver, cmdFilter); } Intent broadcastIntent = new Intent(CMD_TOAST_BROADCAST); broadcastIntent.putExtra("cmd_value", str + action); appContext.sendBroadcast(broadcastIntent, null); break; } case EventDeliveryAck: message.setDelivered(true); break; case EventReadAck: message.setAcked(true); break; // add other events in case you are interested in default: break; } } }; EMChatManager.getInstance().registerEventListener(eventListener); EMChatManager.getInstance().addChatRoomChangeListener(new EMChatRoomChangeListener() { private final static String ROOM_CHANGE_BROADCAST = "easemob.demo.chatroom.changeevent.toast"; private final IntentFilter filter = new IntentFilter(ROOM_CHANGE_BROADCAST); private boolean registered = false; private void showToast(String value) { if (!registered) { // appContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(appContext, intent.getStringExtra("value"), Toast.LENGTH_SHORT).show(); } }, filter); registered = true; } Intent broadcastIntent = new Intent(ROOM_CHANGE_BROADCAST); broadcastIntent.putExtra("value", value); appContext.sendBroadcast(broadcastIntent, null); } @Override public void onChatRoomDestroyed(String roomId, String roomName) { showToast(" room : " + roomId + " with room name : " + roomName + " was destroyed"); Log.i("info", "onChatRoomDestroyed=" + roomName); } @Override public void onMemberJoined(String roomId, String participant) { showToast("member : " + participant + " join the room : " + roomId); Log.i("info", "onmemberjoined=" + participant); } @Override public void onMemberExited(String roomId, String roomName, String participant) { showToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberExited=" + participant); } @Override public void onMemberKicked(String roomId, String roomName, String participant) { showToast("member : " + participant + " was kicked from the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberKicked=" + participant); } }); }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device battery level. *//*from ww w . j a va 2s.c om*/ static String getBatteryLevel(Context context) { try { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); // Error checking that probably isn't needed but I added just in case. if (level > -1 && scale > 0) { return Float.toString(((float) level / (float) scale) * 100.0f); } } catch (Exception e) { if (Countly.sharedInstance().isLoggingEnabled()) { Log.i(Countly.TAG, "Can't get batter level"); } } return null; }
From source file:com.shengtao.chat.chatUI.DemoHXSDKHelper.java
/** * ?//from ww w . j a va2 s .c om * ?UI???UI??????? * activityList.size() <= 0 ????????Activity Stack */ protected void initEventListener() { eventListener = new EMEventListener() { private BroadcastReceiver broadCastReceiver = null; @Override public void onEvent(EMNotifierEvent event) { EMMessage message = null; if (event.getData() instanceof EMMessage) { message = (EMMessage) event.getData(); EMLog.d(TAG, "receive the event : " + event.getEvent() + ",id : " + message.getMsgId()); } switch (event.getEvent()) { case EventNewMessage: //????UI,???? if (activityList.size() <= 0) { HXSDKHelper.getInstance().getNotifier().onNewMsg(message); } break; case EventOfflineMessage: if (activityList.size() <= 0) { EMLog.d(TAG, "received offline messages"); List<EMMessage> messages = (List<EMMessage>) event.getData(); HXSDKHelper.getInstance().getNotifier().onNewMesg(messages); } break; // below is just giving a example to show a cmd toast, the app should not follow this // so be careful of this case EventNewCMDMessage: { EMLog.d(TAG, "??"); //??body CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody(); final String action = cmdMsgBody.action;//?action //? ? //message.getStringAttribute(""); EMLog.d(TAG, String.format("??action:%s,message:%s", action, message.toString())); final String str = appContext.getString(R.string.receive_the_passthrough); final String CMD_TOAST_BROADCAST = "easemob.demo.cmd.toast"; IntentFilter cmdFilter = new IntentFilter(CMD_TOAST_BROADCAST); if (broadCastReceiver == null) { broadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(appContext, intent.getStringExtra("cmd_value"), Toast.LENGTH_SHORT) .show(); } }; // appContext.registerReceiver(broadCastReceiver, cmdFilter); } Intent broadcastIntent = new Intent(CMD_TOAST_BROADCAST); broadcastIntent.putExtra("cmd_value", str + action); appContext.sendBroadcast(broadcastIntent, null); break; } case EventDeliveryAck: message.setDelivered(true); break; case EventReadAck: message.setAcked(true); break; // add other events in case you are interested in default: break; } } }; EMChatManager.getInstance().registerEventListener(eventListener); EMChatManager.getInstance().addChatRoomChangeListener(new EMChatRoomChangeListener() { private final static String ROOM_CHANGE_BROADCAST = "easemob.demo.chatroom.changeevent.toast"; private final IntentFilter filter = new IntentFilter(ROOM_CHANGE_BROADCAST); private boolean registered = false; private void showToast(String value) { if (!registered) { // appContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(appContext, intent.getStringExtra("value"), Toast.LENGTH_SHORT).show(); } }, filter); registered = true; } Intent broadcastIntent = new Intent(ROOM_CHANGE_BROADCAST); broadcastIntent.putExtra("value", value); appContext.sendBroadcast(broadcastIntent, null); } @Override public void onChatRoomDestroyed(String roomId, String roomName) { showToast(" room : " + roomId + " with room name : " + roomName + " was destroyed"); Log.i("info", "onChatRoomDestroyed=" + roomName); } @Override public void onMemberJoined(String roomId, String participant) { showToast("member : " + participant + " join the room : " + roomId); Log.i("info", "onmemberjoined=" + participant); } @Override public void onMemberExited(String roomId, String roomName, String participant) { showToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberExited=" + participant); } @Override public void onMemberKicked(String roomId, String roomName, String participant) { showToast("member : " + participant + " was kicked from the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberKicked=" + participant); } }); }
From source file:com.aibasis.parent.DemoHXSDKHelper.java
/** * ?/*from w w w .j a v a 2 s . co m*/ * ?UI???UI??????? * activityList.size() <= 0 ????????Activity Stack */ protected void initEventListener() { eventListener = new EMEventListener() { private BroadcastReceiver broadCastReceiver = null; @Override public void onEvent(EMNotifierEvent event) { EMMessage message = null; if (event.getData() instanceof EMMessage) { message = (EMMessage) event.getData(); EMLog.d(TAG, "receive the event : " + event.getEvent() + ",id : " + message.getMsgId()); } switch (event.getEvent()) { case EventNewMessage: //????UI,???? if (activityList.size() <= 0) { HXSDKHelper.getInstance().getNotifier().onNewMsg(message); } break; case EventOfflineMessage: if (activityList.size() <= 0) { EMLog.d(TAG, "received offline messages"); List<EMMessage> messages = (List<EMMessage>) event.getData(); HXSDKHelper.getInstance().getNotifier().onNewMesg(messages); } break; // below is just giving a example to show a cmd toast, the app should not follow this // so be careful of this case EventNewCMDMessage: { EMLog.d(TAG, "??"); //??body CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody(); final String action = cmdMsgBody.action;//?action //? ? //message.getStringAttribute(""); EMLog.d(TAG, String.format("??action:%s,message:%s", action, message.toString())); final String str = appContext.getString(R.string.receive_the_passthrough); final String CMD_TOAST_BROADCAST = "easemob.demo.cmd.toast"; IntentFilter cmdFilter = new IntentFilter(CMD_TOAST_BROADCAST); if (broadCastReceiver == null) { broadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(appContext, intent.getStringExtra("cmd_value"), Toast.LENGTH_SHORT) .show(); } }; // appContext.registerReceiver(broadCastReceiver, cmdFilter); } Intent broadcastIntent = new Intent(CMD_TOAST_BROADCAST); broadcastIntent.putExtra("cmd_value", str + action); appContext.sendBroadcast(broadcastIntent, null); break; } case EventDeliveryAck: message.setDelivered(true); break; case EventReadAck: message.setAcked(true); break; // add other events in case you are interested in default: break; } } }; EMChatManager.getInstance().registerEventListener(eventListener); EMChatManager.getInstance().addChatRoomChangeListener(new EMChatRoomChangeListener() { private final static String ROOM_CHANGE_BROADCAST = "easemob.demo.chatroom.changeevent.toast"; private final IntentFilter filter = new IntentFilter(ROOM_CHANGE_BROADCAST); private boolean registered = false; private void showToast(String value) { if (!registered) { // appContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(appContext, intent.getStringExtra("value"), Toast.LENGTH_SHORT).show(); } }, filter); registered = true; } Intent broadcastIntent = new Intent(ROOM_CHANGE_BROADCAST); broadcastIntent.putExtra("value", value); appContext.sendBroadcast(broadcastIntent, null); } @Override public void onChatRoomDestroyed(String roomId, String roomName) { showToast(" room : " + roomId + " with room name : " + roomName + " was destroyed"); Log.i("info", "onChatRoomDestroyed=" + roomName); } @Override public void onMemberJoined(String roomId, String participant) { showToast("member : " + participant + " join the room : " + roomId); Log.i("info", "onmemberjoined=" + participant); } @Override public void onMemberExited(String roomId, String roomName, String participant) { showToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberExited=" + participant); } @Override public void onMemberKicked(String roomId, String roomName, String participant) { showToast("member : " + participant + " was kicked from the room : " + roomId + " room name : " + roomName); Log.i("info", "onMemberKicked=" + participant); } }); }
From source file:com.tumaku.msmble.HM10Activity.java
@Override public void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(TumakuBLE.WRITE_SUCCESS); filter.addAction(TumakuBLE.READ_SUCCESS); filter.addAction(TumakuBLE.DEVICE_CONNECTED); filter.addAction(TumakuBLE.DEVICE_DISCONNECTED); filter.addAction(TumakuBLE.SERVICES_DISCOVERED); filter.addAction(TumakuBLE.NOTIFICATION); filter.addAction(TumakuBLE.WRITE_DESCRIPTOR_SUCCESS); this.registerReceiver(mBroadcastReceiver, filter); if (mTumakuBLE.isConnected()) { mState = WSTATE_NOTIFY_KEY;// w ww . j av a 2 s.c om nextState(); updateInfoText("Resume connection to device"); } else { mState = WSTATE_CONNECT; nextState(); // updateInfoText("Start connection to device"); } }
From source file:org.mycard.net.network.RequestQueue.java
/*** * Enables data state and proxy tracking *///www . ja va2 s . com public synchronized void enablePlatformNotifications() { //if (HttpLog.LOGV) HttpLog.v("RequestQueue.enablePlatformNotifications() network"); if (mProxyChangeReceiver == null) { mProxyChangeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { setProxyConfig(); } }; mContext.registerReceiver(mProxyChangeReceiver, new IntentFilter(Proxy.PROXY_CHANGE_ACTION)); } // we need to resample the current proxy setup setProxyConfig(); }
From source file:edu.mit.mobile.android.locast.data.Sync.java
@Override public void onCreate() { super.onCreate(); nc = NetworkClient.getInstance(this); cr = getApplicationContext().getContentResolver(); registerReceiver(networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:info.guardianproject.gpg.KeyListFragment.java
private void registerReceiver() { LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mBroadcastReceiver, new IntentFilter(GpgApplication.BROADCAST_ACTION_KEYLIST_CHANGED)); }