本文整理匯總了Java中android.content.IntentFilter.addAction方法的典型用法代碼示例。如果您正苦於以下問題:Java IntentFilter.addAction方法的具體用法?Java IntentFilter.addAction怎麽用?Java IntentFilter.addAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.IntentFilter
的用法示例。
在下文中一共展示了IntentFilter.addAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerReceiver
import android.content.IntentFilter; //導入方法依賴的package包/類
public void registerReceiver(Context context, TimeListener timeListener) {
try {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.setPriority(Integer.MAX_VALUE);
context.registerReceiver(this, filter);
this.timeListener = timeListener;
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: onAttachedToWindow
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
// Listen for broadcasts related to user-presence
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_USER_PRESENT);
registerReceiver(mReceiver, filter);
FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView());
mAttached = true;
mVisible = true;
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAttachedToWindow();
}
}
示例3: registerReceiver
import android.content.IntentFilter; //導入方法依賴的package包/類
private void registerReceiver() {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constants.BROADCAST_SMS_SENT);
broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Constants.BROADCAST_SMS_SENT)) {
alertEnabled = false;
setButtonState();
//TODO for testing
Toasty.info(DetentionAlertActivity.this, "Alert sms has been sent").show();
}
}
};
registerReceiver(broadcastReceiver, intentFilter);
}
示例4: registerReceiver
import android.content.IntentFilter; //導入方法依賴的package包/類
/**
* 去電時:
* 未接:phone_state=OFFHOOK;
* 掛斷:phone_state=IDLE
* 來電時:
* 未接:phone_state=RINGING
* 已接:phone_state=OFFHOOK;
* 掛斷:phone_state=IDLE
*/
//public void registerCallStateListener(Context context, PhoneStateListener listener) {
// try {
// //獲取電話通訊服務
// TelephonyManager tpm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// tpm.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
// } catch (Exception e) {
// e.printStackTrace();
// }
//}
public void registerReceiver(Context context, PhoneListener phoneListener) {
try {
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.PHONE_STATE");
filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
filter.setPriority(Integer.MAX_VALUE);
context.registerReceiver(this, filter);
this.phoneListener = phoneListener;
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: initBroadcastReceiver
import android.content.IntentFilter; //導入方法依賴的package包/類
private void initBroadcastReceiver() {
mBroadcastManager = LocalBroadcastManager.getInstance(getActivity());
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(AppDelegate.ACTION_T_ORDER_FORM_SEARCH);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
arguments = intent.getStringExtra(AppDelegate.ACTION_T_ORDER_FORM_SEARCH);
keyword = intent.getStringExtra(AppDelegate.KEYWORD);
mSwipeRefreshLayout.setRefreshing(true);
isLoading = true;
saveCurrentTime(TAG);
pageIndex = 1;
isFirstLoading = true;
onBackgrounds();
}
};
mBroadcastManager.registerReceiver(mReceiver, intentFilter);
}
示例6: initialize
import android.content.IntentFilter; //導入方法依賴的package包/類
/**
* Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity.
*
* @param cordova The context of the main Activity.
* @param webView The CordovaWebView Cordova is running in.
*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
this.connectionCallbackContext = null;
// We need to listen to connectivity events to update navigator.connection
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
if (this.receiver == null) {
this.receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// (The null check is for the ARM Emulator, please use Intel Emulator for better results)
if(NetworkManager.this.webView != null)
updateConnectionInfo(sockMan.getActiveNetworkInfo());
}
};
webView.getContext().registerReceiver(this.receiver, intentFilter);
}
}
示例7: SunmiInnerPrinterModule
import android.content.IntentFilter; //導入方法依賴的package包/類
public SunmiInnerPrinterModule(ReactApplicationContext reactContext) {
super(reactContext);
reactApplicationContext = reactContext;
Intent intent = new Intent();
intent.setPackage("woyou.aidlservice.jiuiv5");
intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService");
reactContext.startService(intent);
reactContext.bindService(intent, connService, Context.BIND_AUTO_CREATE);
bitMapUtils = new BitmapUtils(reactContext);
IntentFilter mFilter = new IntentFilter();
mFilter.addAction(OUT_OF_PAPER_ACTION);
mFilter.addAction(ERROR_ACTION);
mFilter.addAction(NORMAL_ACTION);
mFilter.addAction(COVER_OPEN_ACTION);
mFilter.addAction(COVER_ERROR_ACTION);
mFilter.addAction(KNIFE_ERROR_1_ACTION);
mFilter.addAction(KNIFE_ERROR_2_ACTION);
mFilter.addAction(OVER_HEATING_ACITON);
mFilter.addAction(FIRMWARE_UPDATING_ACITON);
getReactApplicationContext().registerReceiver(receiver, mFilter);
Log.d("PrinterReceiver", "------------ init ");
}
示例8: onCreate
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// initialize the UI
setContentView(R.layout.activity_msg_sender);
guiSetButtonListeners();
guiUpdateInitState();
// initialize the WDSim API
SimWifiP2pSocketManager.Init(getApplicationContext());
// register broadcast receiver
IntentFilter filter = new IntentFilter();
filter.addAction(SimWifiP2pBroadcast.WIFI_P2P_STATE_CHANGED_ACTION);
filter.addAction(SimWifiP2pBroadcast.WIFI_P2P_PEERS_CHANGED_ACTION);
filter.addAction(SimWifiP2pBroadcast.WIFI_P2P_NETWORK_MEMBERSHIP_CHANGED_ACTION);
filter.addAction(SimWifiP2pBroadcast.WIFI_P2P_GROUP_OWNERSHIP_CHANGED_ACTION);
mReceiver = new SimWifiP2pBroadcastReceiver(this);
registerReceiver(mReceiver, filter);
}
示例9: onCreate
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getArguments();
state = bundle.getString("state");
paraMap.put("userId", Login.getInstance().getUserId());
paraMap.put("moduleId", ModuleUtil.getModuleId("公告消息"));
paraMap.put("Readstatu", state);
/*注冊廣播獲取搜索關鍵字*/
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("Msg_KeyWord");
getActivity().registerReceiver(mReceiver, intentFilter);
}
示例10: register
import android.content.IntentFilter; //導入方法依賴的package包/類
/**
* register BroadcastReceiver to monitor USB events
* @param context
*/
public synchronized void register() {
if (mPermissionIntent == null) {
if (DEBUG) Log.i(TAG, "register:");
final Context context = mWeakContext.get();
if (context != null) {
mPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0);
final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
context.registerReceiver(mUsbReceiver, filter);
}
mDeviceCounts = 0;
mHandler.postDelayed(mDeviceCheckRunnable, 1000);
}
}
示例11: onCreate
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
final IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_DISCONNECT);
registerReceiver(mDisconnectActionBroadcastReceiver, filter);
}
示例12: scanBluetooth
import android.content.IntentFilter; //導入方法依賴的package包/類
private void scanBluetooth() {
bluetoothReceiverRegistered = true;
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(bluetoothReceiver, filter);
if (mBluetoothAdapter.isDiscovering()) {
mBluetoothAdapter.cancelDiscovery();
}
mBluetoothAdapter.startDiscovery();
}
示例13: getLocalBroadcastFilter
import android.content.IntentFilter; //導入方法依賴的package包/類
public static IntentFilter getLocalBroadcastFilter() {
IntentFilter intentFilter = new IntentFilter();
String[] BROADCAST_ACTIONS = {
VIEW_FOLDER_CHANGED.ACTION,
CREATE_FOLDER.ACTION
};
for (String action : BROADCAST_ACTIONS) {
intentFilter.addAction(action);
}
return intentFilter;
}
示例14: onStart
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
protected void onStart() {
super.onStart();
Log.d(TAG, "onStart()");
mStopped = false;
unregisterNetworkReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SHUTDOWN);
intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
intentFilter.addAction(PlayerService.PLAYER_SERVICE_STARTED);
intentFilter.addAction(ACTION_HDMI_PLUGGED);
registerReceiver(mReceiver, intentFilter);
isTVMode = TVUtils.isTV(mContext);
mLockRotation = mPreferences.getBoolean(KEY_LOCK_ROTATION, false);
mHideSubtitles = mPreferences.getBoolean(KEY_HIDE_SUBTITLES, false);
mNetworkBookmarksEnabled = mPreferences.getBoolean(KEY_NETWORK_BOOKMARKS, true);
mSubsFavoriteLanguage = mPreferences.getString(KEY_SUBTITLES_FAVORITE_LANGUAGE, Locale.getDefault().getISO3Language());
setLockRotation(mLockRotation);
updateSizes();
mSurfaceController.setVideoFormat(Integer.parseInt(mPreferences.getString(KEY_PLAYER_FORMAT, "-1")),
Integer.parseInt(mPreferences.getString(KEY_PLAYER_AUTO_FORMAT, "-1")));
if (LibAvos.isAvailable()) {
VideoPreferencesFragment.resetPassthroughPref(mPreferences);
LibAvos.setPassthrough(Integer.valueOf(mPreferences.getString("force_audio_passthrough_multiple","0")));
LibAvos.setDownmix(ArchosFeatures.isAndroidTV(this)&&!"AFTM".equals(Build.MODEL)?0:1);//not with firestick
}
//if not started from floating player, we have to stop our video
Intent intent = new Intent(this, PlayerService.class);
bindService(intent, mPlayerServiceConnection, BIND_AUTO_CREATE);
if(PlayerService.sPlayerService!=null)
postOnPlayerServiceBind();
else
mIsReadytoStart = true;
getIntent().putExtra(LAUNCH_FROM_FLOATING_PLAYER, false);
}
示例15: onStart
import android.content.IntentFilter; //導入方法依賴的package包/類
@Override
protected void onStart() {
super.onStart();
receiver = new Receiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
intentFilter.addDataScheme("package");
this.registerReceiver(receiver, intentFilter);
}