Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6720931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:16:13+00:00 2026-05-26T09:16:13+00:00

Well, i am an Android newbie. I am trying to write an application which

  • 0

Well, i am an Android newbie. I am trying to write an application which has one activity which starts another activity (Preference Activity), and one BoradcastReceiver. They are all in three different files. My question is: How to share Preferences betweens these components, e.g. how to read preferences that are set in Preference Activity from Broadcast Receiver?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:16:14+00:00Added an answer on May 26, 2026 at 9:16 am

    I have asked this same exact question before and here is the code I used:

    public class BootupReceiver extends BroadcastReceiver {
    
    private static final boolean BOOTUP_TRUE = true;
    private static final String BOOTUP_KEY = "bootup";
    
    @Override
    public void onReceive(Context context, Intent intent) {
    
        if(getBootup(context)) {
            NotificationManager NotifyM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            Notification Notify = new Notification(R.drawable.n,
                    "NSettings Enabled", System.currentTimeMillis());
    
            Notify.flags |= Notification.FLAG_NO_CLEAR;
            Notify.flags |= Notification.FLAG_ONGOING_EVENT;
    
            RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.notification);
            Notify.contentView = contentView;
    
            Intent notificationIntent = new Intent(context, Toggles.class);
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
            Notify.contentIntent = contentIntent;
    
                        int HELO_ID = 00000;
    
            NotifyM.notify(HELLO_ID, Notify);
        }
    
        Intent serviceIntent = new Intent();
        serviceIntent.setAction("com.leozar100.myapp.NotifyService");
        context.startService(serviceIntent);
    }
    
    public static boolean getBootup(Context context){
        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(BOOTUP_KEY, BOOTUP_TRUE);
    }
    }
    

    The service that I start does nothing I just initiate one because I think it just helps the broadcast receiver work. Also this broadcast receiver is registered in my manifest like so:

    <receiver android:name=".BootupReceiver">
            <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <category android:name="android.intent.category.HOME" />
            </intent-filter>
    </receiver>
    

    Which starts on bootup requiring the permission android.permission.RECEIVE_BOOT_COMPLETED

    Reference to my question can be found here

    P.S. Welcome to stackoverflow

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application that starts an activity and is running well. I
Extreme Android developer newbie here...well, new to Android development, not development in general. I
we have an app which is available for ipad, iphone, android as well as
The Android class SQLiteOpenHelper has a method to return a readable database as well
I have developed an Android application and had it tested on emulator as well
I am new to android application. My Android application works well on emulator but
I am a newbie to graphics in Android (although I am pretty well-versed with
android newbie here. My first game involves a custom view, which is going to
I need to parse Json in Android, as a newbie in Json as well
well , i am into android development since 4 months now (yes a newbie),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.