2013年4月25日星期四

onNewIntent() lifecycle and registered listeners


I'm using a singleTop Activity to receive intents from a search-dialog via onNewIntent().
What I noticed is that onPause() is called before onNewIntent(), and then afterwards it callsonResume(). Visually:
  • search dialog initiated
  • search intent fired to activity
  • onPause()
  • onNewIntent()
  • onResume()
The problem is that I have listeners registered in onResume() that get removed in onPause(), but they are needed inside of the onNewIntent() call. Is there a standard way to make those listeners available?


onNewIntent() is meant as entry point for singleTop activities which already run somewhere else in the stack and therefor can't call onCreate(). From activities lifecycle point of view it's therefore needed to call onPause() before onNewIntent(). I suggest you rewrite your activity to not use these listeners inside of onNewIntent(). For example most of the time my onNewIntent() methods simply looks like this:
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // getIntent() should always return the most recent
    setIntent(intent);
}
With all setup logic happening in onResume() by utilizing getIntent().

Vine For Android Coming Soon, According To Co-Founder Dom Hofmann


Vine is an interesting take on video social networks, allowing you to upload only 6 seconds of video at a time with random cuts. Being an iOS exclusive, it has exploded in popularity recently. This obviously left Android folks wondering when then app would get to us, because unlike Instagram, this is actually a unique and cool app.

In a recent interview, the co-founder of Vine, Dom Hofmann, talked about building his app and keeping it simple. It’s an interesting read, so hit the source link to read the entire thing. But an important tidbit he mentioned is that the Android app is coming “soon.” That’s awesome to hear, as I’m sure many of us would love to use it. Would you use Vine if it was available to you?

Millions Of Android Devices Infected With A New Strain Of Malware


A new strain of Android malware, that has managed to find its way onto millions of devices, has recently been exposed. Despite the fact that Android has improved considerably over the past couple of years as a platform, the issue of malware lingers over the entire Google-made ecosystem as constant black cloud. With Android being of an open-source nature, malicious apps find it considerably easier to operate and thrive on the devices running Google’s mobile OS.

The latest reports reveal that this particular strain of malware, aptly named “BadNews”, has been concealed within 32 different apps coming from four different developer accounts. The figures from Google Play suggest that the total number of downloads to be anywhere from two million all the way up to nine million. Thus being a small portion of the total Android user base, the malware is still a major cause for concern.

“BadNews” sends users fake alerts which point to other dodgy apps, some of which will secretly sign them up to premium SMS services. Moreover, the IMEI number of the infected device is sent back to the servers run by the dishonest individuals behind it.

Reports claim that Google has already scrambled to clear the 32 infected apps, while it still stays doubtful whether Google plans to further invest resources into stopping these kinds of apps from making it to devices in the first place.