本文整理了Java中android.app.Activity.sendBroadcast()
方法的一些代码示例,展示了Activity.sendBroadcast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.sendBroadcast()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:sendBroadcast
暂无
代码示例来源:origin: aa112901/remusic
@Override
public void run() {
try {
playlistsManager.insertLists(mContext, playlist.id, musics);
Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
mContext.sendBroadcast(intent);
dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
代码示例来源:origin: jingle1267/android-utils
/**
* 删除程序的快捷方式
*
* @param activity Activity
*/
public static void delShortcut(Activity activity) {
Intent shortcut = new Intent(
"com.android.launcher.action.UNINSTALL_SHORTCUT");
// 快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
activity.getString(R.string.app_name));
String appClass = activity.getPackageName() + ""
+ activity.getLocalClassName();
ComponentName comp = new ComponentName(activity.getPackageName(),
appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
Intent.ACTION_MAIN).setComponent(comp));
activity.sendBroadcast(shortcut);
}
}
代码示例来源:origin: jingle1267/android-utils
/**
* 为程序创建桌面快捷方式
*
* @param activity Activity
* @param resId 图标资源ID
* @param shortCutName 图标名称,在桌面上显示的名字
*/
public static void addShortcut(Activity activity, int resId, String shortCutName) {
Intent shortcut = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT");
// 快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName);
shortcut.putExtra("duplicate", false); // 不允许重复创建
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(activity, activity.getClass().getName());
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
// 快捷方式的图标
ShortcutIconResource iconRes = ShortcutIconResource.fromContext(
activity, resId);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
activity.sendBroadcast(shortcut);
}
代码示例来源:origin: ac-pm/Inspeckage
activity.sendBroadcast(i, null);
Util.sb = new StringBuilder();
i.putExtra("PID",pid);
activity.sendBroadcast(i, null);
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param intent
* @see android.content.ContextWrapper#sendBroadcast(android.content.Intent)
*/
public void sendBroadcast(Intent intent) {
mActivity.sendBroadcast(intent);
}
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param intent
* @param receiverPermission
* @see android.content.ContextWrapper#sendBroadcast(android.content.Intent,
* java.lang.String)
*/
public void sendBroadcast(Intent intent,
String receiverPermission) {
mActivity.sendBroadcast(intent, receiverPermission);
}
代码示例来源:origin: werbhelius/MyCalendarDemo
public static void startAlarmService(Activity activity){
Intent startAlarmServiceIntent = new Intent(activity,AlarmServiceBroadcastReceiver.class);
activity.sendBroadcast(startAlarmServiceIntent,null);
}
}
代码示例来源:origin: NightscoutFoundation/xDrip
public static void staticRefreshBGCharts(boolean override) {
reset_viewport = true;
if (activityVisible || override) {
Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA);
mActivity.sendBroadcast(updateIntent);
}
}
代码示例来源:origin: jamorham/xDrip-plus
public static void staticRefreshBGCharts(boolean override) {
reset_viewport = true;
if (activityVisible || override) {
Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA);
mActivity.sendBroadcast(updateIntent);
}
}
代码示例来源:origin: hss01248/FaceDetect
/**
* 保存后用广播扫描,Android4.4以下使用这个方法
* @author YOLANDA
*/
public static void saveImageSendBroadcast(Activity activity,String filePath){
activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + filePath)));
// com.hss01248.lib.activity. sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory()+ filePath)));
}
代码示例来源:origin: JakePrim/PrimFilePicker
/**
* 更新相册
*/
public void refreshFile() {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File file = new File(imagePaths);
Uri uri = Uri.fromFile(file);
intent.setData(uri);
mContext.get().sendBroadcast(intent);
}
代码示例来源:origin: jareddlc/OpenFit
public void sendIntent(String intentName) {
Log.d(LOG_TAG, "Sending Intent: " + intentName);
Intent i = new Intent(intentName);
getActivity().sendBroadcast(i);
}
代码示例来源:origin: wasdennnoch/AndroidN-ify
@Override
public boolean onPreferenceClick(Preference preference) {
getActivity().sendBroadcast(new Intent(ACTION_FIX_INVERSION).setPackage("com.android.systemui"));
return false;
}
});
代码示例来源:origin: jareddlc/OpenFit
public void sendNotificationApplications() {
Log.d(LOG_TAG, "Sending Intent: " + OpenFitIntent.INTENT_SERVICE_NOTIFICATION_APPLICATIONS);
Intent i = new Intent(OpenFitIntent.INTENT_SERVICE_NOTIFICATION_APPLICATIONS);
i.putExtra(OpenFitIntent.INTENT_EXTRA_MSG, OpenFitIntent.INTENT_SERVICE_NOTIFICATION_APPLICATIONS);
i.putExtra(OpenFitIntent.INTENT_EXTRA_DATA, appManager.getNotificationApplications());
getActivity().sendBroadcast(i);
}
代码示例来源:origin: ApolloAuto/apollo-DuerOS
@Override
public void onPause() {
super.onPause();
Intent intent = new Intent(CAR_RADIO_PLAY_INFO_PAUSE_ACTION);
intent.setPackage(CAR_RADIO_PACKAGENAME);
getActivity().sendBroadcast(intent);
}
代码示例来源:origin: gigabytedevelopers/FireFiles
private void startServer() {
Intent intent = new Intent(ACTION_START_FTPSERVER);
intent.putExtras(getArguments());
getActivity().sendBroadcast(intent);
}
代码示例来源:origin: ApolloAuto/apollo-DuerOS
@Override
public void onResume() {
super.onResume();
Intent intent = new Intent(CAR_RADIO_PLAY_INFO_START_ACTION);
intent.setPackage(CAR_RADIO_PACKAGENAME);
getActivity().sendBroadcast(intent);
updateFeedView(mMusicInfo);
}
代码示例来源:origin: ApolloAuto/apollo-DuerOS
@Override
public void onResume() {
super.onResume();
IntentFilter intentFilter = new IntentFilter(CAR_RADIO_PLAY_INFO);
getActivity().registerReceiver(mFeedReceiver, intentFilter);
Intent intent = new Intent(CAR_RADIO_PLAY_INFO_START_ACTION);
intent.setPackage(CAR_RADIO_PACKAGENAME);
getActivity().sendBroadcast(intent);
}
代码示例来源:origin: org.seleniumhq.selenium/selenium-android-driver
public void setOnline(boolean online) throws WebDriverException {
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, online ? 0 : 1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", online);
getActivity().sendBroadcast(intent);
}
代码示例来源:origin: ApolloAuto/apollo-DuerOS
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateTime();
WeatherUtil.getInstance().addObserver(this);
WeatherUtil.getInstance().init(getActivity().getApplicationContext());
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TRAFFIC_RESPONSE_ACTION);
getActivity().registerReceiver(mReceiver, intentFilter);
getActivity().sendBroadcast(new Intent(TRAFFIC_REQUEST_ACTION));
}
内容来源于网络,如有侵权,请联系作者删除!