lunedì 24 dicembre 2012

Install Application programmatically on Android - Stack Overflow

Install Application programmatically on Android - Stack Overflow

Android: install .apk programmatically

How to download apk from internet and install it.

Android: install .apk programmatically - Stack Overflow

Checking Intent Availability in Android | Grokking Android

Good article for check package installation

public static boolean isAvailable(Context ctx, Intent intent) {
final PackageManager mgr = ctx.getPackageManager();
  List list =
  mgr.queryIntentActivities(intent,
  PackageManager.MATCH_DEFAULT_ONLY);
  return list.size() > 0;
}

Checking Intent Availability in Android | Grokking Android

martedì 11 dicembre 2012

Use POI with Excel template




POIFSFileSystem fs = new POIFSFileSystem(      	        new FileInputStream("template.xls"));  HSSFWorkbook wb = new  HSSFWorkbook(fs, true);

Will load an xls, preserving its structure (macros included). You can then modify it,

HSSFSheet sheet1 = wb.getSheet("Data"); ...

and then save it.

FileOutputStream fileOut = new FileOutputStream("new.xls");   wb.write(fileOut);  fileOut.close();





http://stackoverflow.com/questions/714172/poi-using-excel-templates

Android app call Contact list intent

Abstract code :
..


Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);

...


In android manifest put this :

 android:name="android.permission.READ_CONTACTS"/>
 
 
From caller intent

@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
  super.onActivityResult(reqCode, resultCode, data);

  switch (reqCode) {
    case (PICK_CONTACT) :
      if (resultCode == Activity.RESULT_OK) {
        Uri contactData = data.getData();
        Cursor c =  managedQuery(contactData, null, null, null, null);
        if (c.moveToFirst()) {
          String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          // TODO Whatever you want to do with the selected contact name.
        }
      }
      break;
  }
}




Full example in stack overflow