This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Animation wobble = AnimationUtils.loadAnimation(this, R.anim.wobble); | |
//Now we can play the animation like this on our chosen UI object, in this case our button1 object: | |
button1.startAnimation(wobble); | |
//https://www.safaribooksonline.com/library/view/learning-java-by/9781784398859/ch05s05.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogUtil { | |
private static final String TAG = "IntentDump"; | |
public static void dumpIntent(Intent i){ | |
Bundle bundle = i.getExtras(); | |
if (bundle != null) { | |
Set<String> keys = bundle.keySet(); | |
StringBuilder stringBuilder = new StringBuilder(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Bitmap resizeBitmap(Bitmap b, int newWidthDp){ | |
Float density = getResources().getDisplayMetrics().density; | |
int newWidth = newWidthDp * Math.round(density); | |
int width = b.getWidth(); | |
int height = b.getHeight(); | |
float scaleWidth = ((float) newWidth) / width; | |
float ratio = (float) width / newWidth; | |
int newHeight = (int) (height / ratio); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isSharingWiFi(final WifiManager manager) | |
{ | |
try | |
{ | |
final Method method = manager.getClass().getDeclaredMethod("isWifiApEnabled"); | |
method.setAccessible(true); //in the case of visibility change in future APIs | |
return (Boolean) method.invoke(manager); | |
} | |
catch (final Throwable ignored) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.mortenjust.wtfbbqwwjd" | |
android:versionCode="10" | |
android:versionName="1.1.0.6" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int getVersion() { | |
int v = 0; | |
try { | |
Log.d("mj.store", "package name is: "+mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).packageName); | |
Log.d("mj.store", "versionName name is: "+mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode); | |
Log.d("mj.store", "versionCode name is: "+mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName); | |
v = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode; | |
} catch (PackageManager.NameNotFoundException e) { | |
// Huh? Really? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// android { ... | |
// defaultconfig ... | |
applicationVariants.all { variant -> | |
variant.outputs.each { output -> | |
def file = output.outputFile | |
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + variant.versionCode+ ".apk")) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.INTERNET"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent i = new Intent(this, WatchFaceActivity.class); | |
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); | |
startActivity(i); | |
finish(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Handler().postDelayed(new Runnable() | |
{ | |
@Override | |
public void run() | |
{ | |
// your code here | |
} | |
}, 1000/* 1sec delay */); |