I have an application that contains a main Activity, which has a very simple screen with all application setup options and a few user selections. The main screen buttons start other Activities.
(1) I'm now implementing a bluetooth scanner into the application and i would like to be able to edit settings and establish a bluetooth connection on the main Activity and pass that connection (via Bundle or Parcelable perhaps?) to the other Activities.
I looked up Bundle as a way to pass the connection, but it appears to only accept primitive and basic types as values. I noticed Intent.putExtra(String, Parcelable) was available, but Parcel sort of confused me. What would be the best way to implement this, or is it even possible?
some relevant code:
//subclass definitions for the Runnables which start the applications in their own threads
private final Handler smsHandler = new Handler();
private final Handler smsOutHandler = new Handler();
private final Runnable smsIntentRunnable = new Runnable() {
public void run() {
Intent smsIntent = new Intent(smsMobile.this, smsActivity.class);
startActivity(smsIntent);
}
};
private final Runnable smsOutIntentRunnable = new Runnable() {
public void run() {
Intent smsOutIntent = new Intent(smsMobile.this, smsOutActivity.class);
startActivity(smsOutIntent);
}
};
//button listeners located in onCreate(), which start the Activities
newTicket.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
smsHandler.post(smsIntentRunnable);
}
});
updateTicket.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
smsOutHandler.post(smsOutIntentRunnable);
}
});
(2) Could I also pass a database connection? I understand that SQLiteOpenHelper must be subclassed, which could complicate IPC, but thought it might still be possible somehow?