Oct 25, 2011

Start Battery use checking using Intent.ACTION_POWER_USAGE_SUMMARY

Start Battery use checking using Intent.ACTION_POWER_USAGE_SUMMARY

package com.AndroidBatteryUsage;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.widget.Toast;

public class AndroidBatteryUsageActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = packageManager.resolveActivity(intent, 0);

if(resolveInfo == null){
Toast.makeText(AndroidBatteryUsageActivity.this,
"No suitable Activity found!",
Toast.LENGTH_LONG).show();
}else{
startActivity(intent);
}
}
}




No comments:

Post a Comment

Infolinks In Text Ads