当前位置: 首页>>代码示例>>Java>>正文


Java PendingIntent.getBroadcast方法代码示例

本文整理汇总了Java中android.app.PendingIntent.getBroadcast方法的典型用法代码示例。如果您正苦于以下问题:Java PendingIntent.getBroadcast方法的具体用法?Java PendingIntent.getBroadcast怎么用?Java PendingIntent.getBroadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.PendingIntent的用法示例。


在下文中一共展示了PendingIntent.getBroadcast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pinShortcutToHomeScreen

import android.app.PendingIntent; //导入方法依赖的package包/类
private void pinShortcutToHomeScreen(Context context) {
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    if (shortcutManager.isRequestPinShortcutSupported()) {
        ShortcutInfo pinShortcutInfo = createShortcutInfo(this);
        Intent resultIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, resultIntent, 0);
        shortcutManager.requestPinShortcut(pinShortcutInfo, pendingIntent.getIntentSender());
    } else {
        Toast.makeText(context, R.string.device_does_not_support_shortcut_pinning, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:akexorcist,项目名称:Android-O-Feature,代码行数:12,代码来源:PinningActivity.java

示例2: getDeleteIntent

import android.app.PendingIntent; //导入方法依赖的package包/类
public PendingIntent getDeleteIntent(Context context) {
  int       index = 0;
  long[]    ids   = new long[notifications.size()];
  boolean[] mms   = new boolean[ids.length];

  for (NotificationItem notificationItem : notifications) {
    ids[index] = notificationItem.getId();
    mms[index++]   = notificationItem.isMms();
  }

  Intent intent = new Intent(context, DeleteNotificationReceiver.class);
  intent.setAction(DeleteNotificationReceiver.DELETE_NOTIFICATION_ACTION);
  intent.putExtra(DeleteNotificationReceiver.EXTRA_IDS, ids);
  intent.putExtra(DeleteNotificationReceiver.EXTRA_MMS, mms);
  intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));

  return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:NotificationState.java

示例3: onCreate

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    Intent shutdownIntent = new Intent(this, ShutdownReceiver.class);
    PendingIntent shutdownPI = PendingIntent.getBroadcast(
            this, PENDING_SHUTDOWN_ID, shutdownIntent, 0
    );
    Notification notification = new NotificationCompat.Builder(this)
            .setSmallIcon(android.R.drawable.ic_dialog_map)
            .setContentTitle(getString(R.string.notification_title))
            .setContentText(getString(R.string.notification_text))
            .setTicker(getString(R.string.app_name))
            .setContentIntent(shutdownPI)
            .build();

    startForeground(NOTIFICATION_ID, notification);
    MockWalker.get(this).setStarted(true);
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:20,代码来源:MockWalkerService.java

示例4: onCreate

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    receiver = new MyReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction("clicked");
    filter.addAction("download has been paused");
    filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    this.registerReceiver(receiver, filter);

    bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.launcher512_qihoo);
    pendingIntent = PendingIntent.getBroadcast(
            this, 1, new Intent().setAction("clicked"), PendingIntent.FLAG_UPDATE_CURRENT);
    manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

}
 
开发者ID:BittleDragon,项目名称:MyRepository,代码行数:20,代码来源:MainActivity.java

示例5: showPermissionNotification

import android.app.PendingIntent; //导入方法依赖的package包/类
@SuppressLint("ResourceType")
    public void showPermissionNotification() {
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent(
                INTENT_ACTION_OPEN_PERMISSIONS), 0);
        String title = this.context.getResources().getString(R.string.permissions_notification_title);
        ((android.app.NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE))
                .notify(
                        2,
                        new Builder(this.context)
                                .setSmallIcon(17301543)
                                .setContentTitle(title)
                                .setContentText(
                                        this.context.getResources().getString(R.string.permissions_notification_text))
                                .setContentIntent(pendingIntent).setOngoing(true).setPriority(1).build());
//        PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent(INTENT_ACTION_OPEN_PERMISSIONS), 0);
//        String title = this.context.getResources().getString(R.string.permissions_notification_title);
//        ((NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(2, new Builder(this.context).setSmallIcon(17301543).setContentTitle(title).setContentText(this.context.getResources().getString(R.string.permissions_notification_text)).setContentIntent(pendingIntent).setOngoing(true).setPriority(1).build());
    }
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:19,代码来源:NotificationTrayManager.java

示例6: updateAppWidget

import android.app.PendingIntent; //导入方法依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    setCountersDK(context);
    setCountersIO(context);
    setCountersFromPreferences(context);

    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.kaem_widget);
    views.setTextViewText(R.id.dk_kaem_users, dkUsersCount);
    views.setTextViewText(R.id.dk_kaem_projects, dkProjectsCount);
    views.setTextViewText(R.id.dk_kaem_teams, dkTeamsCount);
    views.setTextViewText(R.id.dk_kaem_lookups, dkLookupsCount);

    views.setTextViewText(R.id.io_kaem_users, ioUsersCount);
    views.setTextViewText(R.id.io_kaem_projects, ioProjectsCount);
    views.setTextViewText(R.id.io_kaem_teams, ioTeamsCount);
    views.setTextViewText(R.id.io_kaem_lookups, ioLookupsCount);

    // Pending intent for refresh button
    Intent intent = new Intent(REFRESH_BUTTON);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setOnClickPendingIntent(R.id.REFRESH_BUTTON, pendingIntent);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:KAEM,项目名称:android-widget,代码行数:28,代码来源:KaemWidget.java

示例7: updateAppWidgetLayout

import android.app.PendingIntent; //导入方法依赖的package包/类
private static void updateAppWidgetLayout(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    Filter filter = getFilter(context, appWidgetId);

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.list_widget);

    Intent serviceIntent = new Intent(context, ListWidgetService.class);
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    serviceIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    // Tell ListView where to get the data from
    remoteViews.setRemoteAdapter(R.id.list_widget_list_view, serviceIntent);

    remoteViews.setEmptyView(R.id.list_widget_list_view, R.id.list_widget_empty_view);
    if (filter.getQuery() == null) {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.select_a_filter_long));
    } else {
        remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.no_notes_found_after_search));
    }

    // Rows - open note
    final Intent onClickIntent = new Intent(context, ListWidgetProvider.class);
    onClickIntent.setAction(AppIntent.ACTION_CLICK_LIST_WIDGET);
    onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(context, 0,
            onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setPendingIntentTemplate(R.id.list_widget_list_view, onClickPendingIntent);

    // Plus icon - new note
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_add, ShareActivity.createNewNoteIntent(context, filter));

    // Logo - open query
    Intent openIntent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class));
    openIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_icon, PendingIntent.getActivity(context, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    Intent filterSelectIntent = new Intent(context, FilterSelectDialogActivity.class);
    filterSelectIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    filterSelectIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setOnClickPendingIntent(R.id.list_widget_header_bar, PendingIntent.getActivity(context, 0, filterSelectIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    remoteViews.setTextViewText(
            R.id.list_widget_header_filter,
            filter.getName());

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:50,代码来源:ListWidgetProvider.java

示例8: onClick

import android.app.PendingIntent; //导入方法依赖的package包/类
public void onClick(View view) {
    // Configure the widget
    WidgetProviderVideo.configure(VideoWidgetConfigure.this, mAppWidgetId, mContentType);

    // Ask to update the widget because the initial update was skipped
    // (the configuration was not yet available when it was received by the provider)
    Intent intent = new Intent(VideoWidgetConfigure.this, WidgetProviderVideo.class);
    intent.setAction(WidgetProviderVideo.INITIAL_UPDATE_ACTION);
    intent.setData(Uri.parse(String.valueOf(mAppWidgetId)));    // Fill data with a dummy value to avoid the "extra beeing ignored" optimization of the PendingIntent
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(VideoWidgetConfigure.this, 0, intent, 0);
    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);

    // Tell the AppWidgetHost that the configuration is done for this widget id
    notifyResult(Activity.RESULT_OK);

    // Configuration done => exit the activity
    finish();
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:21,代码来源:VideoWidgetConfigure.java

示例9: scheduleLine

import android.app.PendingIntent; //导入方法依赖的package包/类
public void scheduleLine(String line, int lineNo) {
    ParsedLine parsedLine = parseLine(line);
    if (parsedLine == null) {
        return;
    }
    ExecutionTime time;
    try {
        time = ExecutionTime.forCron(parser.parse(parsedLine.cronExpr));
    }
    catch (IllegalArgumentException e) {
        return;
    }
    DateTime next = time.nextExecution(DateTime.now());
    Intent intent = new Intent(context, AlarmReceiver.class);
    intent.putExtra(INTENT_EXTRA_LINE_NAME, line);
    intent.putExtra(INTENT_EXTRA_LINE_NO_NAME, lineNo);
    PendingIntent alarmIntent = PendingIntent.getBroadcast(context, lineNo, intent,
            PendingIntent.FLAG_UPDATE_CURRENT); // update current to replace the one used
                                                // for cancelling any previous set alarms
    alarmManager.setExact(AlarmManager.RTC_WAKEUP, next.getMillis(), alarmIntent);
    IO.logToLogFile(context.getString(R.string.log_scheduled_v2, lineNo + 1, parsedLine.runExpr,
            DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss.SSSS").print(next)));
}
 
开发者ID:Faerbit,项目名称:android-crond,代码行数:24,代码来源:Crond.java

示例10: createFavoriteActionIntent

import android.app.PendingIntent; //导入方法依赖的package包/类
/** Create intent to launch {@link FavoriteActionBroadcastReceiver}. */
private PendingIntent createFavoriteActionIntent()
{
  Intent intent = new Intent( app, FavoriteActionBroadcastReceiver.class );
  return PendingIntent.getBroadcast(
    app, FavoriteActionBroadcastReceiver.REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT
  );
}
 
开发者ID:dr0id3v,项目名称:QuotesOnDesign,代码行数:9,代码来源:DefaultNotificationsPresenter.java

示例11: start

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void start(Context context)
{
    AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, TimedGPSFixReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + 60000L, 60000L, pi);
}
 
开发者ID:bsautermeister,项目名称:GeoFencer,代码行数:10,代码来源:TimedGPSFixReceiver.java

示例12: onReceive

import android.app.PendingIntent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	if (!LinphoneService.isReady()) {
		return;
	} else {
		boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
		LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
		LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
		LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
		if (lc == null) return;
		
		String action = intent.getAction();
		if (action == null) {
			Log.i("[KeepAlive] Refresh registers");
			lc.refreshRegisters();
			//make sure iterate will have enough time, device will not sleep until exit from this method
			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				Log.e("Cannot sleep for 2s", e);
			} finally {
				//make sure the application will at least wakes up every 10 mn
				Intent newIntent = new Intent(context, KeepAliveReceiver.class);
				PendingIntent keepAlivePendingIntent = PendingIntent.getBroadcast(context, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);

				AlarmManager alarmManager = ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE));
				Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
			}
		} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
			Log.i("[KeepAlive] Screen is on, enable");
			lc.enableKeepAlive(true);
		} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_OFF)) {
			Log.i("[KeepAlive] Screen is off, disable");
			lc.enableKeepAlive(false);
		}
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:38,代码来源:KeepAliveReceiver.java

示例13: getToggleIntent

import android.app.PendingIntent; //导入方法依赖的package包/类
/**
 * Returns a pending intent, suitable for use as a tap intent, that causes a complication to be
 * toggled and updated.
 */
static PendingIntent getToggleIntent(
        Context context, ComponentName provider, int complicationId) {
    Intent intent = new Intent(context, ComplicationToggleReceiver.class);
    intent.putExtra(EXTRA_PROVIDER_COMPONENT, provider);
    intent.putExtra(EXTRA_COMPLICATION_ID, complicationId);

    // Pass complicationId as the requestCode to ensure that different complications get
    // different intents.
    return PendingIntent.getBroadcast(
            context, complicationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
开发者ID:googlesamples,项目名称:android-WearComplicationProvidersTestSuite,代码行数:16,代码来源:ComplicationToggleReceiver.java

示例14: addScrollOnClick

import android.app.PendingIntent; //导入方法依赖的package包/类
private static void addScrollOnClick(Context context, RemoteViews updateViews, int widgetId, Class providerClass) {
    Uri widgetUri = ContentUris.withAppendedId(CONTENT_URI, widgetId);
    Intent intent = new Intent(WIDGET_UPDATE_ACTION, widgetUri, context, providerClass);
    intent.putExtra(WIDGET_ID, widgetId);
    intent.putExtra("ts", System.currentTimeMillis());
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    updateViews.setOnClickPendingIntent(R.id.account_icon, pendingIntent);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:AccountWidget.java

示例15: setAlarm

import android.app.PendingIntent; //导入方法依赖的package包/类
public static void setAlarm(Context context) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    if (alarmManager != null) {
        long start = System.currentTimeMillis();
        Intent in = new Intent("ALARM_RECEIVER");
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, in, PendingIntent.FLAG_CANCEL_CURRENT);
        alarmManager.set(AlarmManager.RTC_WAKEUP, start + 86400 * 1000, pi);
    }
}
 
开发者ID:zhaobao,项目名称:AppsTimeline,代码行数:10,代码来源:AlarmUtil.java


注:本文中的android.app.PendingIntent.getBroadcast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。