Skip to content

Instantly share code, notes, and snippets.

View caseycrites's full-sized avatar

Casey W Crites caseycrites

  • San Francisco, CA
View GitHub Profile
33 /**
32 * If set the adapter will call requery() on the cursor whenever a content change
31 * notification is delivered. Implies {@link #FLAG_REGISTER_CONTENT_OBSERVER}.
30 *
29 * @deprecated This option is discouraged, as it results in Cursor queries
28 * being performed on the application's UI thread and thus can cause poor
27 * responsiveness or even Application Not Responding errors. As an alternative,
26 * use {@link android.app.LoaderManager} with a {@link android.content.CursorLoader}.
25 */
24 @Deprecated
public HashSet<String> getSet(String key, HashSet<String> defValue) {
String setString = this.getString(key, null);
if (setString != null) {
try {
JSONArray jsonArray = new JSONArray(setString);
int length = jsonArray.length();
HashSet<String> set = new HashSet<String>(length);
for (int i = 0; i < length; i++) {
set.add(jsonArray.getString(i));
}
// TODO: we need to find another way to implement RelativeLayout
// This implementation cannot handle every case
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
...
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >
<LinearLayout
android:id="@+id/unread_indicator"
android:layout_width="4dp"
android:layout_height="fill_parent"
>>> def divide():
... return 5/0
...
>>> def go():
... try:
... return divide()
... except ZeroDivisionError:
... return "divided by zero"
...
>>> go()
DroidCafe cafe = new DroidCafe(new BasicAuth("key", "secret"));
cafe.get("https://go.urbanairship.com/api/apids/d17d5a62-a937-4375-9207-b50f5901ba35/", new Handler() {
@Override
public void handleMessage(Message message) {
HttpResponse result = (HttpResponse) message.obj;
switch (message.what) {
case (DroidCafe.REQUEST_RESULT):
try {
Log.e(TAG, EntityUtils.toString(result.getEntity()));
} catch (IllegalStateException e) {
if (fileSize < 1024) {
response = parseFloat(fileSize).toFixed(2) + " bytes"
} else if (fileSize < 1048576) {
response = (parseFloat(fileSize)/1024).toFixed(2) + " KB"
} else {
response = (parseFloat(fileSize)/1048576).toFixed(2) + " MB"
}
caseycrites@montana:~/ua% curl -X POST -u "gmho5E0CRsOnWr1kPzEFcQ:jZ1ZAxqyQgqzusCeUlh4Hw" -H "Content-type: application/json" --data '{"aliases": ["homecoming_ua_demo"], "android": {"alert": "command line, bitches."}}' https://go.urbanairship.com/api/push/
Forbidden%
11:31 AM S3nsat10n
Do you have to create an IDL in order to interact with a service running in another process inside your own app? Or can you bind to it like you would a service running in the main process?
11:31 AM evancharlton
you can just bind to it
11:31 AM lov
S3nsat10n: it depends.
11:31 AM pfn
S3nsat10n, another process = need idl
11:31 AM evancharlton
IDL is pretty much just for IPC as far as I know
@caseycrites
caseycrites / gist:1405859
Created November 29, 2011 18:32
Sound file as an asset failure
1318 NotificationService W error loading sound for file:///android_asset/cat.wav
1318 ion: Prepare failed. W status=0x1
1318 NotificationService W at android.media.MediaPlayer.prepare(Native Method)
1318 NotificationService W at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90)