Skip to content

Instantly share code, notes, and snippets.

@agusbrand
Created March 17, 2015 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agusbrand/641d859d10e5d695f42f to your computer and use it in GitHub Desktop.
Save agusbrand/641d859d10e5d695f42f to your computer and use it in GitHub Desktop.
import android.app.Activity;
String strClassName = Activity.class.getName(); // android.app.Activity
String silly = "Silly String!";
Class someKindOfClass = silly.getClass();
String strSillyClassName = someKindOfClass.getName(); // java.lang.String
String strCurrentClass = this.getClass().getName(); // e.g. the current Activity
Log.v(strCurrentClass, "Debug tag is current class.");
// User fields, including variables of type LoginInfo and UserPreferences
// Misc user methods
class LoginInfo
{
// Login info fields
// Login/Logout methods
// Can access User fields/methods
}
class Preferences
{
// User preference fields
// Get/Set preference methods
// Reset preferences method
// Can access User fields/methods
}
}
public class User {
class LoginInfo {}
public static class ServerInfo {}
{
}
}
new Thread() {
public void run()
{
doWorkHere();
}
}.start();
Button myButton = (Button) findViewById(R.id.ButtonToClick);
myButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SimpleDateFormat formatter = new SimpleDateFormat("h:mm:ss a");
String strWhen = formatter.format(new Date());
TextView myTextview = (TextView)
findViewById(R.id.TextViewToShow);
myTextview.setText("Clicked at " + strWhen);
}
});
Log.v(DEBUG_TAG, "this Class name: " + this.getClass().getName());
Log.v(DEBUG_TAG, "this extends interface named: " + this.getClass().getInterfaces()[0].getName());
Log.v(DEBUG_TAG, "this Enclosing class name: " +this.getClass().getEnclosingClass().getName());
Log.v(DEBUG_TAG, "this Is anonymous class? " + this.getClass().isAnonymousClass());
Log.v(DEBUG_TAG, "ClassChaosActivity.this Class name: " + ClassChaosActivity.this.getClass().getName());
Log.v(DEBUG_TAG, "ClassChaosActivity.this Super Class name: " + ClassChaosActivity.this.getClass().getSuperclass().getName());
Log.v(DEBUG_TAG, "ClassChaosActivity.this Is anonymous class? " + ClassChaosActivity.this.getClass().isAnonymousClass());
DateFormat a;
Date anotherCurDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMMM d 'at' hh:mm a 'in the year' yyyy G");
String formattedDateString = formatter.format(anotherCurDate);
String strVowels = "aeiou";
char astrVowels[] = { 'a', 'e', 'i', 'o', 'u' };
byte abyteVowels[] = { 'a', 'e', 'i', 'o', 'u' };
byte abyteVowelsU[] = { '\u0061', '\u0065','\u0069','\u006F','\u0075' };
String uVowels = new String("\u0061\u0065\u0069\u006F\u0075");
CharSequence csVowels = (CharSequence) new String("aeiou");
StringBuffer sbVowels = new StringBuffer("a" + "e" + "iou");
StringBuilder sVowelBuilder = new StringBuilder();
sVowelBuilder.append('a');
sVowelBuilder.append("eio");
sVowelBuilder.append('\u0075');
String strVowels1 = "aeiou";
String strVowels2 = new String("aeiou");
String strVowels3 = new String(sVowelBuilder);
String strVowels4 = new String(sbVowels);
String strVowels5 = new String(uVowels);
String strVowels6 = new String(abyteVowels2);
String strVowels7 = new String(abyteVowelsU);
String strAppName = getResources().getString(R.string.app_name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment