Skip to content

Instantly share code, notes, and snippets.

View hitesh-dhamshaniya's full-sized avatar
🎯
Focusing

Hitesh Dhamshaniya hitesh-dhamshaniya

🎯
Focusing
View GitHub Profile
try {
PackageInfo info = getPackageManager().getPackageInfo("your.package.name", PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
@hitesh-dhamshaniya
hitesh-dhamshaniya / gist:bd6493da0b38657af0ca
Created February 28, 2015 13:25
Test Application Commad Line in Android
./adb shell monkey -p com.example.android.notepad -v 2000
@hitesh-dhamshaniya
hitesh-dhamshaniya / Live Wallpaper Direct
Created May 30, 2015 14:40
Android Live Wallpaper Direct show
if (android.os.Build.VERSION.SDK_INT > 15)
{
bundle.setAction("android.service.wallpaper.CHANGE_LIVE_WALLPAPER");
bundle.putExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT", new ComponentName(com/loard/ganesha/MyService.getPackage().getName(), com/loard/ganesha/MyService.getCanonicalName()));
} else
{
bundle.setAction("android.service.wallpaper.LIVE_WALLPAPER_CHOOSER");
}
class PInfo {
private String appname = "";
private String pname = "";
private String versionName = "";
private int versionCode = 0;
private Drawable icon;
private void prettyPrint() {
Log.v("LOG===> ", appname + "\t" + pname + "\t" + versionName
+ "\t" + versionCode);
@hitesh-dhamshaniya
hitesh-dhamshaniya / gist:611360ad271169c28238
Created August 27, 2015 06:32
How to capture particular Layout Screenshot in android.
View view = relativeLayout; // Your layout which you want to capture
view.measure(View.MeasureSpec.makeMeasureSpec(1200, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(1920, View.MeasureSpec.UNSPECIFIED));
//view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100,bytes);
and save bitmap in your desire location
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
***************** Java ******************
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
Uri imageUri = Uri.parse("/sdcard/Aa.png");
//Uri imageUri = Uri.parse("/storage/emulated/0/designapp/Aa.png");
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(imageUri, "image/*");
intent.putExtra("png", "image/*");
startActivityForResult(Intent.createChooser(intent,"Set AS"), 1000);
User for Set Image as wallpaper, Contact Picture and other....
import android.content.Context;
import android.graphics.Rect;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import com.dhl.tiktail.BuildConfig;
import java.lang.reflect.Field;
/*
* Copyright 2015 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software