Skip to content

Instantly share code, notes, and snippets.

View dmpatel151282's full-sized avatar

Dharmesh Patel dmpatel151282

View GitHub Profile
Get extract-ikconfig in kernel-source/scripts/
$mkdir extract-uImage
$cd extract-uImage
$cp {kernel-source}/scripts/extract-ikconfig
Dump uImage skip 1024 bytes
$cp {uImage/what/you/want} uImage
$dd if=uImage of=dd_uImage bs=1024 skip=1
Android Error in Eclipse: "Unable to execute dex: Cannot merge new index 65799 into a non-jumbo instruction!"
Solution:- Add dex.force.jumbo=true to project.properties file.
Get current global time zone:
adb shell settings get global time_zone
Set a time zone:
adb shell settings put global time_zone Europe/Madrid
This way, developers can change other global settings too.
There are three ways to do this.
1.
private static final ScheduledExecutorService worker =
Executors.newSingleThreadScheduledExecutor();
void someMethod() {
...
Runnable task = new Runnable() {
public void run() {
/* Do something... */
There are generally three ways to do this:
1. As some of the answers suggested, you could distinguish the cases of your activity being created for the first time and being restored from savedInstanceState.
This is done by overriding onSaveInstanceState and checking the parameter of onCreate.
2. You could lock the activity in one orientation by adding android:screenOrientation="portrait" (or "landscape") to <activity> in your manifest.
<activity android:screenOrientation="landscape">
3. You could tell the system that you meant to handle screen changes for yourself by specifying android:configChanges="screenOrientation" in the <activity> tag.
Bitmap snapshot = null;
Drawable drawable = null;
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_AUTO); // Quality of the snpashot
try {
view.layout(0, 0, 110, 110);
snapshot = Bitmap.createBitmap(view.getDrawingCache(true)); // You can tell how to crop the snapshot and whatever in this method
drawable = new BitmapDrawable(snapshot);
} catch(Exception ex) {
ex.printStackTrace();
Add below permission in Androidmenifest.xml file.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Code snippet:-
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String deviceID =telephonyManager.getDeviceId();
#define _GNU_SOURCE
#include <sched.h>
Set:-
cpu_set_t mask;
CPU_ZERO(&mask);
pid_t pid = gettid(); // Thread. For pid, use getpid()
CPU_SET(1, &mask);
There are three ways to achieve this in Android.
Through Worker thread:-
private static final ScheduledExecutorService worker =
Executors.newSingleThreadScheduledExecutor();
void someMethod() {
...
Runnable task = new Runnable() {
From PNG file to RLE file
ffmpeg -vcodec png -i logo.png -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 initlogo.rle
Note:- Replace format as per requirement.
From RLE file to PNG file
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 1024x768 -i initlogo.rle -vcodec png logo.png