Astro file browser and Intents
I was able to get Astro to launch my activity when I selected a certain filetype. However, I don't know how to grab the intent when my activity starts!
public class Viewer extends ListActivity{
....
// Flag if receiver is registered
private boolean mReceiversRegistered = false;
// I think this is the broadcast you need for something like an incoming call
private String INCOMING_CALL_ACTION = "android.intent.action.VIEW";
// Define a handler and a broadcast receiver
private final Handler mHandler = new Handler();
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)开发者_StackOverflow社区 {
// Handle reciever
String mAction = intent.getAction();
Toast.makeText(context,"Found with passed context", Toast.LENGTH_LONG).show();
Toast.makeText(BallLidarViewer.this, "Found with my context", toast.LENGTH_LONG).show();
System.out.print("FOUND");
Log.d("FOUND","FOUND");
if(mAction.equals(INCOMING_CALL_ACTION)) {
// Do your thing
}
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
....
}
}
I can't get any of my test output code to be run when my activity starts. What am I doing wrong? Thank you!
If I get you right, you can simply call getIntent in your onCreate
method.
To get the bundle of the intent, call getExtras on the intent.
精彩评论