I want to know how I can send an object of a class in fragment ,to broadcast receiver.
When I call object directly with fragment object , it is always null.
Example :
Here I create a receiver class. this class handles custom Notification layout events . everything works correct except for a record.pause(). MediaRecorder object is always null in this receiver ,while in the Sample_Fragment which records audio it is not. hence recording does not stop.
Receiver Class :
public class Sample_Receiver extends BroadcastReceiver {
Sample_Fragment fragment = new Sample_Fragment();
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if ("pause".equalsIgnoreCase(action)) {
record.pause();
}
}
}
Update :
I could fix the problem through inner BroadcastReceiver.