tags:

views:

29

answers:

2

Hi All,

I have an handler in one activity, and I would like to use sendBroadcast in order to start receiver of another application(different APK).

I cant do this since i am into an Handler and i`am losing the scope of my activity.

Any idea how I could achieve this idea?

some code:

private Handler mHandler = new Handler() {
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case INSTALL_COMPLETE:
                 // here I wanna start my extern application via broadcasting!!

                startApplication();
                break;
            default:
                break;
        }
    }

if broadcasting wont work through handler, any other ideas would be welcome,

thanks.

A: 

Use a PendingIntent

schwiz
A: 

It was my mistake, I can use startBroadcast/application/service inside Handler.

thanks anyway:

 private final int INSTALL_COMPLETE = 1;
private Handler mHandler = new Handler()
{
    public void handleMessage(Message msg)
    {
        switch (msg.what)
        {
            case INSTALL_COMPLETE:

                // finish the activity posting result
                // setResultAndFinish(msg.arg1);
                startApplication();
                break;
            default:
                break;
        }
    }

    private void startApplication()
    {
        String intentName = g_szIntentName;
        Intent i = new Intent(intentName);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        sendBroadcast(i);
    }
};
rayman