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 7978343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:28:13+00:00 2026-06-04T09:28:13+00:00

Hi friends i have a problem…i want to send string data form activity to

  • 0

Hi friends i have a problem…i want to send string data form activity to service, and i have saved the data into shared preference..mine everything is working, i able to pass data to the service class..but problem is that, if i change the string into shared preference and run my project from eclipse then i am not facing any problem, but i open the application from device or emulator..and then change my string..that time value is not updating in service class, in service class its taking the old data.
I if debug its showing the value, but in device showing old value. Any help please

This is the code i tried...
Activity class,From where i sent the value to to the service class using alarm manager

@Override
    protected void onResume() {
        super.onResume();
// Preference Satting
        prefs = PreferenceManager
                .getDefaultSharedPreferences(this);
}

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

                    alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

                    myIntent = new Intent(PZAlarmTTSActivity.this, TtsService.class);

                    passedText = prefs.getString("text", "<unset>");
                    //Log.i("passed Text  :", passedText);

                    // Passing the value to the service
                    Bundle bundle = new Bundle();
                    bundle.putString("k_key", passedText);
                    myIntent.putExtras(bundle);
                    Log.i("key Data  :  ", passedText);

                    // Pending intent to launch when the alarm triggers
                    pendintIntent = PendingIntent.getService(PZAlarmTTSActivity.this, 0,
                            myIntent, 0);
                    // Sets alarm to trigger
                    alarmManager.set(AlarmManager.RTC_WAKEUP, calender.getTimeInMillis(), pendintIntent);

}


Service class, where i want to receive the string value


@Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        Toast.makeText(this, "service started", Toast.LENGTH_LONG).show();

        Bundle bundle = intent.getExtras();  
        String data = bundle.getString("k_key"); // Here data is not updating in 2nd  case
        Log.i("From service class : ", data);
    }
  • 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-06-04T09:28:14+00:00Added an answer on June 4, 2026 at 9:28 am

    see As Doc says:

    onStart:This method is deprecated.

    Implement onStartCommand(Intent, int, int) instead.

    onStartCommand :Called by the system every time a client explicitly starts the service by calling startService(Intent), providing the arguments it supplied and a unique integer token representing the start request. Do not call this method directly.

    you need to use Threading to get latest value in your service or start your service by using startService every time for getting new value from SharedPreferences bez once service is started your onStart method is not called if service is already running

    this maybe help you!!!

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

Sidebar

Related Questions

Hi friends i have a one problem to solve...I want to destroy the service
Friends, I have a problem, now I want to access an element with jquery
Hello friends i am having problem in parsing jSON web services data I have
I run into an interesting problem I want to understand. I have a table:
Friends, I have a strange need and cannot think my way through the problem.
I have a users table and a friends table. I want to get the
friends, i have a EditText on simple activity with a button. when every i
friends i have problem with using get or set in class in c# when
Hallo,friends we have the following problem syms t u0 u1 u0=sin(t); R1= diff(u0,'t',2)+u0-u0^3; u1=dsolve('D2u1+u1=R1','t')
I have a problem selecting 6 random friends This is the query I've got

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.