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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:40:39+00:00 2026-05-27T09:40:39+00:00

I am looking for the best way to notify a user that they need

  • 0

I am looking for the best way to notify a user that they need to install a package by handling the possibility of an external package not being found.

In this particular case I am wishing to implement the TODO: if intent not found, notification on need to have GSF in the C2DMMessaging class

public static void register(Context context,
        String senderId) {
    Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(GSF_PACKAGE);
    registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(EXTRA_SENDER, senderId);
    context.startService(registrationIntent);
    // TODO: if intent not found, notification on need to have GSF

}

I’m thinking that I should look for the error W/ActivityManager( 60): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) }: not found

But how to trap that error?

UPDATE – Just found that the call to startService returns a ComponentName instance which is null if the service failed to start so my code now looks like this

ComponentName name = context.startService(registrationIntent);
// TODO: if intent not found, notification on need to have GSF
if(name == null){
    Util.log_debug_message("@@@@ REG INTENT FAILED");
}else{
    Util.log_debug_message("@@@@ REG INTENT SUCCEEDED");
}

(For anyone looking for this solution Util.log_debug is just a function I created in a util class to call Log.d so just replace this with a call to Log.d)

Which seems to work just fine so I guess I need to send a broadcast message with an extra to indicate the package needs to be installed. The receiver could then show an alert dialog explaining that the user must install!

What does the user need to install? and how would the user install whatever is needed to be installed?

Thanks in advance for any tips, pointers code snippets and help

  • 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-27T09:40:40+00:00Added an answer on May 27, 2026 at 9:40 am

    I have resolved this issue – In the activity that calls the C2DM registration event I have this code

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
        register();
    }
    
    protected void register() {
        String reg_id = C2DMessaging.getRegistrationId(this);
        String email = Util.getEmail(this);
        if(reg_id == null || reg_id == ""){
            Util.log_debug_message("@@@@ Registering with C2DM");
            Toast.makeText(this, "Registering with C2DM", Toast.LENGTH_LONG).show();
            if(C2DMessaging.register(this, Config.C2DM_SENDER)){
                showLoadingDialog();
            }else{
                showInstallGSFDialog();
            }
        }else if(email == null || email =="-1"){
            Util.log_debug_message("**** Updating server with new auth token");
            register_with_server();
        }
    }
    
    private void showInstallGSFDialog(){
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("ERROR!");
        alertDialog.setMessage("Please ensure you have a valid GMail account set up on your phone." +
        " This application needs to use Google's C2DM service");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
    
             return;
    
          } });
        alertDialog.show();
      }
    

    and I changed the C2DMessaging.register to a boolean method and added the check to ensure that the service started like so…

    /**
     * Initiate c2d messaging registration for the current application
     */
    public static boolean register(Context context, String senderId) {
        boolean res = false;
        Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
        registrationIntent.setPackage(GSF_PACKAGE);
        registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
                PendingIntent.getBroadcast(context, 0, new Intent(), 0));
        registrationIntent.putExtra(EXTRA_SENDER, senderId);
        ComponentName name = context.startService(registrationIntent);
        // if intent not found, notification on need to have GSF by NOT setting resukt of this function to true
        if(name == null){
            Util.log_debug_message("@@@@ REG INTENT FAILED");
        }else{
            Util.log_debug_message("@@@@ REG INTENT SUCCEEDED");
            res = true;
        }
        return res;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for the best way to check that a database login exists
I looking for the best way to implement a block that lists all terms
I'm looking for the best way to verify that a given method (the unit)
I'm looking for the best way how to use external variables in PHP with
I'm looking for the best way to start an intent from a class that
I'm looking for the best way to use an external properties file with an
I'm looking for the best way to go about forcing the user to fill
I'm looking for the best way to basically get a unique number (guaranteed, not
I'm looking for best way of using session within zf application. At first I
Looking for the best way to set-up an iPhone project in XCode ... namely:

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.