Context sendBroadcast - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context sendBroadcast method.

This code example shows how to use the following methods:getContentResolver, getFilesDir, openFileOutput, sendBroadcast, sleep
                    "dfrsRsFMrFpk++mSt6SoxXaMbn0LL2u1CD4PCEiQMGt+lK3/3TmRTKNs+23sYS7Ahjxj0udDAkEA" + 
                    "p57Nj65WNaWeYiOfTwKXkLj8l29H5NbaGWxPT0XkWr4PvBOFZVH/wj0/qc3CMVGnv11+DyO+QUCN" + 
                    "SqBB5aRe8g=="; 
 
    private void overrideSettings(String key, String value) throws Exception {
        assertTrue(Settings.Secure.putString(mContext.getContentResolver(), key, value));
        Thread.sleep(1000);
    } 
 
    private void overrideCert(String value) throws Exception {
        overrideSettings(PINLIST_CERTIFICATE_KEY, value);
    } 
 
    private String readPins() throws Exception {
        return IoUtils.readFileAsString(PINLIST_CONTENT_PATH);
    } 
 
    private String readCurrentVersion() throws Exception {
        return IoUtils.readFileAsString("/data/misc/keychain/metadata/version"); 
    } 

9
CodeRank
This code example shows how to use the following methods:getContentResolver, getFilesDir, openFileOutput, sendBroadcast, sleep
                    "dfrsRsFMrFpk++mSt6SoxXaMbn0LL2u1CD4PCEiQMGt+lK3/3TmRTKNs+23sYS7Ahjxj0udDAkEA" + 
                    "p57Nj65WNaWeYiOfTwKXkLj8l29H5NbaGWxPT0XkWr4PvBOFZVH/wj0/qc3CMVGnv11+DyO+QUCN" + 
                    "SqBB5aRe8g=="; 
 
    private void overrideSettings(String key, String value) throws Exception {
        assertTrue(Settings.Secure.putString(mContext.getContentResolver(), key, value));
        Thread.sleep(1000);
    } 
 
    private void overrideCert(String value) throws Exception {
        overrideSettings(PINLIST_CERTIFICATE_KEY, value);
    } 
 
    private String readPins() throws Exception {
        return IoUtils.readFileAsString(PINLIST_CONTENT_PATH);
    } 
 
    private String readCurrentVersion() throws Exception {
        return IoUtils.readFileAsString("/data/misc/keychain/metadata/version"); 
    } 

7
CodeRank
This code example shows how to use the following methods:sendBroadcast
 
    protected static String LOG_TAG = "K9RemoteControl";
 
    public static void set(Context context, Intent broadcastIntent) {
        broadcastIntent.setAction(K9RemoteControl.K9_SET);
        context.sendBroadcast(broadcastIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION);
    } 
 
    public static void fetchAccounts(Context context, K9AccountReceptor receptor) {
        Intent accountFetchIntent = new Intent();
        accountFetchIntent.setAction(K9RemoteControl.K9_REQUEST_ACCOUNTS);
        AccountReceiver receiver = new AccountReceiver(receptor);
        context.sendOrderedBroadcast(accountFetchIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION, receiver, null, Activity.RESULT_OK, null, null);
    } 
 
} 
 
 
7
CodeRank
This code example shows how to use the following methods:sendBroadcast
    public void onReceive(Context context, Intent intent) {
        abortBroadcast(); //So we have a problem if we abort this broadcast, because we can't calibrate :(
 
        //The sloppy way of launching the default camera taking app 
        Intent i = new Intent("android.intent.action.CAMERA_BUTTON");
        context.sendBroadcast(i);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:sendBroadcast
        // after writing the file to sd, invoke this to scan a single file without callback 
        public static Uri scan(Context aContext, String aPath) {
            File file = new File(aPath);
            Uri uri = Uri.fromFile(file);
            Intent scanFileIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
            aContext.sendBroadcast(scanFileIntent);
            return uri;
        } 
    } 
 
    public static class Viewer { 
        public static void viewImage(Context aContext, Uri aUri) {
            view(aContext, aUri, "image/*");
        } 
 
        public static void view(Context aContext, Uri aUri, String aMime) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(aUri, aMime);
            aContext.startActivity(intent);
6
CodeRank
This code example shows how to use the following methods:sendBroadcast
 
    private static void sendIntent(Context context, String value) {
        Intent i = new Intent("com.cyanogenmod.SamsungServiceMode.EXECUTE");
        i.putExtra("sub_type", 20); // HSPA Setting
        i.putExtra("data", value);
        context.sendBroadcast(i);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:sendBroadcast, putExtra, setComponent
        Intent grantIntent = new Intent();
        grantIntent.setData(uri);
        grantIntent.addFlags(mode);
        grantIntent.setClass(getContext(),
                service ? ReceiveUriService.class : ReceiveUriActivity.class);
        Intent intent = new Intent();
        intent.setComponent(GRANT_URI_PERM_COMP);
        intent.putExtra("intent", grantIntent);
        intent.putExtra("service", service);
        getContext().sendBroadcast(intent);
    } 
 
    void doTestGrantActivityUriReadPermission(Uri uri) {
        final Uri subUri = Uri.withAppendedPath(uri, "foo");
        final Uri subSubUri = Uri.withAppendedPath(subUri, "bar");
        final Uri sub2Uri = Uri.withAppendedPath(uri, "yes");
        final Uri sub2SubUri = Uri.withAppendedPath(sub2Uri, "no");
 
        // Precondition: no current access. 
        assertReadingContentUriNotAllowed(subUri, "shouldn't read when starting test");
7
CodeRank
This code example shows how to use the following methods:sendBroadcast
        return DownloadManager.getRecommendedMaxBytesOverMobile(mContext);
    } 
 
    @Override 
    public void sendBroadcast(Intent intent) {
        mContext.sendBroadcast(intent);
    } 
 
    @Override 
    public boolean userOwnsPackage(int uid, String packageName) throws NameNotFoundException {
        return mContext.getPackageManager().getApplicationInfo(packageName, 0).uid == uid;
    } 
 
    @Override 
    public void postNotification(long id, Notification notification) {
        /** 
         * TODO: The system notification manager takes ints, not longs, as IDs, but the download 
         * manager uses IDs take straight from the database, which are longs.  This will have to be 
         * dealt with at some point. 
         */ 
6
CodeRank
This code example shows how to use the following methods:sendBroadcast
    static ComponentName getComponentName(Context context) {
        return new ComponentName(context, BookmarkThumbnailWidgetProvider.class);
    } 
 
    public static void refreshWidgets(Context context) {
        context.sendBroadcast(new Intent(
                BookmarkThumbnailWidgetProvider.ACTION_BOOKMARK_APPWIDGET_UPDATE,
                null, context, BookmarkThumbnailWidgetProvider.class));
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:sendBroadcast
     * in the future. 
     * 
     * See also CallerInfoCache in Phone package for more information. 
     */ 
    public static void sendUpdateCallerInfoCacheIntent(Context context) {
        context.sendBroadcast(new Intent(UPDATE_CALLER_INFO_CACHE));
    } 
} 
6
CodeRank

Related Context sendBroadcast Questions & Answers:

Other Context sendBroadcast Examples

33:	        Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
34:	        intent.putExtra(EXTRA_MESSAGE, message);
35:	        context.sendBroadcast(intent);
36:	    }
37:	}

Read More

sendBroadcast Method Overview
Broadcast the given intent to all interested BroadcastReceivers, allowing an optional required permission to be enforced.
See Code Examples for other Android Context Methods: