Install APK file
private void installapk (file file) {
Intent Intent = newintent (Intent.action_view);
Uri data =uri.fromfile (file);
String type = "Application/vnd.android.package-archive";
Intent.setdataandtype (Data,type);
StartActivity (Intent);
}
Uninstall APK file
private void uninstallapk (String packagename) {
Intent Intent = newintent (Intent.action_view);
Uri data = Uri.parse ("package:" + PackageName);
Intent.setdata (data);
StartActivity (Intent);
}
Edit the picture size to keep the picture from deforming.
public static Bitmap Resetimage (Bitmapsourcebitmap,int resetwidth,int resetheight) {
int width =sourcebitmap.getwidth ();
int height =sourcebitmap.getheight ();
int tmpwidth;
int tmpheight;
float ScaleWidth = (float) resetwidth/(float) width;
float ScaleHeight = (float) resetheight/(float) height;
float Maxtmpscale = scalewidth>= scaleheight? Scalewidth:scaleheight;
Keep Not deformed
Tmpwidth = (int) (Maxtmpscale *width);
Tmpheight = (int) (Maxtmpscale *height);
Matrix M = new Matrix ();
M.setscale (Maxtmpscale,maxtmpscale, Tmpwidth, tmpheight);
Sourcebitmap =bitmap.createbitmap (sourcebitmap, 0, 0, sourcebitmap.getwidth (), Sourcebitmap.getheight (), m, false);
Transduction
int x = (tmpwidth-resetwidth)/2;
int y = (tmpheight-resetheight)/2;
Returnbitmap.createbitmap (Sourcebitmap, x, Y, resetwidth,resetheight);
}
Get contacts from your SIM card
Private Cursor getcontacts () {
Uri uri = uri.parse ("Content://sim/adn");
string[] projection = new string[] {"Name", "Phone"};
String selection = null;
string[] Selectionargs = null;
String sortOrder = null;
Return Managedquery (URI, projection, selection, selectionargs,sortorder);
}
Common methods in Android