Skip to content

Instantly share code, notes, and snippets.

private static boolean needToCheckCTA() {
boolean result = false;
Class<?> mClassType = null;
Method mGetIntMethod = null;
try {
mClassType = Class.forName("android.os.SystemProperties");
mGetIntMethod = mClassType.getDeclaredMethod("getInt", String.class, int.class);
Integer v;
try {
v = (Integer) mGetIntMethod.invoke(mClassType, "persist.sys.cta.security", 0);
package com.asus.push.service;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.asus.push.analytics.zAnalytics;
import com.asus.push.receiver.zParsePushBroadcastReceiver;
@SemonCat
SemonCat / zParsePushBroadcastReceiver
Last active August 29, 2015 14:20
zParsePushBroadcastReceiver
package com.asus.push.receiver;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
# For Refactoring SDK ####################################################################
-keepattributes Signature
-keepattributes Exceptions
-keep class com.google.** { *; }
-dontwarn com.google.**
-keep class com.uservoice.** { *; }
-dontwarn com.uservoice.uservoicesdk.**
-keep class retrofit.** { *; }
-dontwarn retrofit.**
-dontwarn android.google.support.**
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23"
defaultConfig {
applicationId "xxxxxxxxxxx"
minSdkVersion 16
targetSdkVersion 22
@SemonCat
SemonCat / getScreenInches.java
Last active October 20, 2015 03:06
Android ScreenInches
private int getScreenInches(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getMetrics(displayMetrics);
int widthPixels = displayMetrics.widthPixels;
int heightPixels = displayMetrics.heightPixels;
float widthDpi = displayMetrics.xdpi;
float heightDpi = displayMetrics.ydpi;
public static void setupWindowTranslucentStatus(Activity activity) {
if (activity.getResources().getIdentifier("windowTranslucentStatus", "attr", "android") != 0) {
Window w = activity.getWindow(); // in Activity's onCreate() for
// instance
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
@SemonCat
SemonCat / shake_anim.java
Created March 16, 2016 07:17
Shake Animation
View view = findViewById(R.id.tv_hello);
RotateAnimation rotateAnimation = new RotateAnimation(-5, 5, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setDuration(1000);
rotateAnimation.setRepeatMode(Animation.REVERSE);
rotateAnimation.setRepeatCount(Animation.INFINITE);
view.startAnimation(rotateAnimation);
new Thread(new Runnable() {
@Override
public void run() {
try {
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
final String token = instanceID.getToken(getApplicationContext().getString(com.asus.robotrtcsdk.R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
runOnUiThread(new Runnable() {
@Override
public void run() {
publishing {
publications {
aar(MavenPublication) {
groupId packageName
version = libraryVersion
artifactId "robotrtcsdk"
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
pom.withXml {
def dependencies = asNode().appendNode('dependencies')