android existing activity read intent of file from OnResume
Posted
by
manhon
on Stack Overflow
See other posts from Stack Overflow
or by manhon
Published on 2013-11-03T15:44:11Z
Indexed on
2013/11/03
15:53 UTC
Read the original article
Hit count: 222
android
|android-intent
I have associated my app with txt file. So user can select a file in File explorer app and select my app to open it. In OnCreate:
Intent intent = getIntent();
String action = intent.getAction();
if (action != null && action.equals(Intent.ACTION_VIEW)) {
txtFilePath = intent.getData().getPath();
}
However, when user did not close my app, and he goes back to file explorer and open another file, OnCreate is not called. OnResusme is called instead. I put below code in OnResume:
Intent intent = getIntent();
String action = intent.getAction();
if (action != null && action.equals(Intent.MAIN)) {
txtFilePath = intent.getData().getPath();
}
However, txtFilePath is null. Why? Thank a lot for help.
© Stack Overflow or respective owner