In the onReceive(), I want to create a new Intent and start a new Activity. After the activity finishes, I want to get back to the same line from where I left for the activity. I know that I cannot use BroadcastReceiver class for achieving this. How can this be achieved? Below is the onReceive() code:
final BroadcastReceiver mPairingRequestRecevier = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(intent.getAction()))
{
final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR);
if (type == BluetoothDevice.PAIRING_VARIANT_PIN)
{
abortBroadcast();
String passkey="hey";
Intent passkeyIntent = new Intent(context.getApplicationContext(),TestActivity.class);
passkeyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
passkeyIntent.putExtra("passkey",passkey);
context.startActivity(passkeyIntent);
Log.d("after returning...",passkey);
}
else
{
Log.d("Unexpected pairingtype:" , type+"");
}
}
}
};
Any idea that can achieve this would be appreciated.