Skip to content

Instantly share code, notes, and snippets.

View gist:803834
// launches the settings screen that lets user turn on gps radio
private void launchGPSOptions() {
final ComponentName toLaunch = new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, 0);
}
View gist:814231
// launches the settings screen that lets user turn on gps radio
private void launchGPSOptions() {
final ComponentName toLaunch = new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, 0);
}
View gist:816045
// put this in your activity
@Override
protected Dialog onCreateDialog(int id) {
if(id == ID_DIALOG_VALIDATE){
ProgressDialog registerDialog = new ProgressDialog(this);
registerDialog.setMessage(getString(R.string.alert_registering_phone));
registerDialog.setIndeterminate(true);
registerDialog.setCancelable(true);
return registerDialog;
View gist:823922
Android Debug Bridge
ADB quickview
* Manage the state of an emulator or device
* Run shell commands on a device
* Manage port forwarding on an emulator or device
* Copy files to/from an emulator or device
In this document
View gist:825568
// launches the settings screen that lets user turn on gps radio
private void launchGPSOptions() {
final ComponentName toLaunch = new ComponentName("com.android.settings","com.android.settings.SecuritySettings");
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(toLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, 0);
}
View gist:827568
public static String bytesToHex(byte[] data) {
if (data==null) {
return null;
} else {
int len = data.length;
String str = "";
for (int i=0; i<len; i++) {
if ((data[i]&0xFF)<16) {
str = str + "0" + java.lang.Integer.toHexString(data[i]&0xFF);
} else {
View gist:827592
package com.mysite.aes;
import javax.crypto.*;
import javax.crypto.spec.*;
public class AES {
static String key = "Z7Y74jNe43F3o15T"; // must be 16-bytes
static String iv = "P0LrHf3nkBo7z46f";
public static String Encrypt(String stringToEncrypt) {
View gist:837091
private void writeToSDCard() {
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
InputStream from = myContext.getResources().openRawResource(rID);
File dir = new java.io.File (root, "pdf");
dir.mkdir();
File writeTo = new File(root, "pdf/" + attachmentName);
FileOutputStream to = new FileOutputStream(writeTo);
View gist:859860
private void writeToSDCard() {
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
InputStream from = myContext.getResources().openRawResource(rID);
File dir = new java.io.File (root, "pdf");
dir.mkdir();
File writeTo = new File(root, "pdf/" + attachmentName);
FileOutputStream to = new FileOutputStream(writeTo);
View gist:879163
CGRect imageFrame = CGRectZero;
imageFrame.size.height = 150;
imageFrame.size.width = 200;
imageFrame.origin.x = 59;
imageFrame.origin.y = 20;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:imageFrame];
imageView.image = [UIImage imageNamed:@"tomatoes.jpg"];
[self.tableView.tableHeaderView addSubview:imageView];
[imageView release];
You can’t perform that action at this time.