FileDocCategorySizeDatePackage
LocalReceiver.javaAPI DocAndroid 5.1 API3272Thu Mar 12 22:22:12 GMT 2015android.app.activity

LocalReceiver

public class LocalReceiver extends android.content.BroadcastReceiver

Fields Summary
Constructors Summary
public LocalReceiver()

    
Methods Summary
public voidonReceive(android.content.Context context, android.content.Intent intent)

        String resultString = LaunchpadActivity.RECEIVER_LOCAL;
        if (BroadcastTest.BROADCAST_FAIL_REGISTER.equals(intent.getAction())) {
            resultString = "Successfully registered, but expected it to fail";
            try {
                context.registerReceiver(this, new IntentFilter("foo.bar"));
                context.unregisterReceiver(this);
            } catch (ReceiverCallNotAllowedException e) {
                //resultString = "This is the correct behavior but not yet implemented";
                resultString = LaunchpadActivity.RECEIVER_LOCAL;
            }
        } else if (BroadcastTest.BROADCAST_FAIL_BIND.equals(intent.getAction())) {
            resultString = "Successfully bound to service, but expected it to fail";
            try {
                ServiceConnection sc = new ServiceConnection() {
                    public void onServiceConnected(ComponentName name, IBinder service) {
                    }

                    public void onServiceDisconnected(ComponentName name) {
                    }
                };
                context.bindService(new Intent(context, LocalService.class), sc, 0);
                context.unbindService(sc);
            } catch (ReceiverCallNotAllowedException e) {
                //resultString = "This is the correct behavior but not yet implemented";
                resultString = LaunchpadActivity.RECEIVER_LOCAL;
            }
        } else if (LaunchpadActivity.BROADCAST_REPEAT.equals(intent.getAction())) {
            Intent newIntent = new Intent(intent);
            newIntent.setAction(LaunchpadActivity.BROADCAST_LOCAL);
            context.sendOrderedBroadcast(newIntent, null);
        }
        try {
            IBinder caller = intent.getIBinderExtra("caller");
            Parcel data = Parcel.obtain();
            data.writeInterfaceToken(LaunchpadActivity.LAUNCH);
            data.writeString(resultString);
            caller.transact(LaunchpadActivity.GOT_RECEIVE_TRANSACTION, data, null, 0);
            data.recycle();
        } catch (RemoteException ex) {
        }