Search code examples
androidappcelerator-mobile

Getting data from intent


I am little confused about getting data from intent of an activity, here is what I am trying to do.

  1. I am opening my first activity
  2. I press home button and my activity(application) goes in background
  3. I go to download folder and select one doc file it gives me Open with feature with my application in list.
  4. I select my application.
  5. Now instead of getting resume it calls create method of activity(I think its ok because second instance of my app(activity is created))
  6. Here I try to get data from intent using intent = activity.getIntent();
  7. But I dont get anything(getting null expecting path of this doc)
  8. If I first open my app with Open with feature(No background activity right now) I get file path successfully but when I pres home button and my app goes background again and if I press my app from application list again intent has same data(expecting null in this case.)

What I am trying to achieve:-

I am simply trying that if user is coming from application list intent data should be null and if he is coming from Open with function then he intent data should be path of file.

One more thing I am trying this behaviour in Appcelerator Titanium but as this is native behaviour(handling life cycle of activity and I can do this in titanium) but having no luck.

Thanks.


Solution

  • I some what manage this by giving my activity as 'singleInstance' in manfiest file. So now I can be sure that at a time same instance is running.

    Now for handling intent data I am registering onNewInstance method. By using this intent data is get affected everytime when I comes from background or when when I select any file to open with my application.

    Thanks.