Skip to content

Instantly share code, notes, and snippets.

@Antarix
Antarix / TimePreference.java
Created Jun 23, 2014
custom TimePreference dialog for preference activity
View TimePreference.java
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TimePicker;
public class TimePreference extends DialogPreference {
private int lastHour=0;
private int lastMinute=0;
@Antarix
Antarix / PhonegapPermission.xml
Created Jun 24, 2014
Permissons for Phongap. You should remove unwanted permissions before before publishing application to play store
View PhonegapPermission.xml
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
View Activity.java
public class ContactsActivity extends Activity {
List<Contact> contacts;
ContactsAdapter contactsAdapter;
ListView contactsList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View gist:0a32a0132eae19cf9470
// just add these few lines of code to your app delegate .m file right before the @implementation part
@implementation NSURLRequest (DSInvalidSSL)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host {
return YES;
}
@end
View gist:eb238c70e2ac46c96aeb
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@Antarix
Antarix / AES.c
Last active Aug 29, 2015 — forked from bricef/AES.c
View AES.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>
@Antarix
Antarix / OpacityHex.txt
Last active Aug 29, 2015
Opacity hex color code.
View OpacityHex.txt
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
@Antarix
Antarix / PreapareListFromXML.java
Last active Dec 12, 2015
fetches data from local Android xml folder having xml file and returns in Arraylist
View PreapareListFromXML.java
public ArrayList<string> prepareListFromXml() {
ArrayList<string> todoItems = new ArrayList<string>();
XmlResourceParser todolistXml = getResources().getXml(R.xml.todolist);
int eventType = -1;
@Antarix
Antarix / round_background.xml
Created Feb 7, 2013
Round background image drawable for android
View round_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<stroke android:width="1dp" android:color="#FFFFFF" />
<gradient
android:startColor="#679031"
android:centerColor="#679031"