Saturday, January 10, 2015

List running service of Android device

The method getRunningServices(int maxNum) of ActivityManager return a list of the services that are currently running. (Note: this method is only intended for debugging or implementing service management type user interfaces)


package com.example.androidgetrunning;

import java.util.List;

import android.support.v7.app.ActionBarActivity;
import android.text.method.ScrollingMovementMethod;
import android.app.ActivityManager;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);

ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);

/*
* maxNum: the maximum number of entries to return in the list.
* The actual number returned may be smaller,
* depending on how many services are running.
*/
int maxNum = 100;
List<ActivityManager.RunningServiceInfo> list = activityManager.getRunningServices(maxNum);

StringBuilder info = new StringBuilder();
info.append("android-coding.blogspot.com" + "\n\n");
info.append("no. of running service: " + list.size() + "\n\n");
for(int i=0; i<list.size(); i++){
info.append(list.get(i).service + "\n\n");
}

TextView texView = new TextView(this);
texView.setMovementMethod(new ScrollingMovementMethod());
texView.setText(info);
setContentView(texView);
}

}

List running application processes of Android device

Call getSystemService(ACTIVITY_SERVICE) to get instance of the ActivityManager. With it, your app can interact with the overall activities running in the system. The method getRunningAppProcesses() return a list of application processes that are running on the device. (Note: this method is only intended for debugging or building a user-facing process management UI)

Example:
package com.example.androidgetrunning;

import java.util.List;

import android.support.v7.app.ActionBarActivity;
import android.text.method.ScrollingMovementMethod;
import android.app.ActivityManager;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);

List<ActivityManager.RunningAppProcessInfo> list = activityManager.getRunningAppProcesses();

StringBuilder info = new StringBuilder();
info.append("android-coding.blogspot.com" + list.size() + "\n\n");
info.append("no. of running application processes: " + list.size() + "\n");
for(int i=0; i<list.size(); i++){
info.append(list.get(i).processName + "\n");
}

TextView texView = new TextView(this);
texView.setMovementMethod(new ScrollingMovementMethod());
texView.setText(info);
setContentView(texView);
}

}


Android Vector Graphics

Tenghui Zhu presents the VectorDrawable and AnimatedVectorDrawable APIs in Android L, which can provide an easy and compact way to represent the drawables. These APIs also helps adding various animations to the drawables, including path morphing.

To learn more about vector drawable support in Android, check out http://goo.gl/fj7gv2


Monday, December 8, 2014

Google Play Services 6.5

Google Play services 6.5 includes new features in Google Maps, Google Drive and Google Wallet as well as the recently launched Google Fit API. Also providing developers with more granular control over which Google Play services APIs your app depends on to help you maintain a lean app.

Google Developer content is now available offline


The Google Developer Platform team recently commenced a program to make a subset of the resources available offline to developers who, because of limited or no broadband, had previously been unable to access them. The kits include the latest and greatest content on it such as videos, documentation and SDKs.

Find out more: http://g.co/GDGDevKitPilot


Wednesday, December 3, 2014

AdMob Interstitials Best Practices

You can grow your mobile app revenue with high-paying AdMob interstitial ads. Implementing these ads in the right way is better for your users and for you. AdMob poiicies are designed to create a positive user experience, so watch this official video to be sure you're doing it right.