All posts by Nandan Dubey

About Nandan Dubey

I am from a small village in Bihar. Currently, I am studying in Indian Institute of Technology(Kanpur) with Computer Science as major.

How to find dependencies in android .so

ndk-depends

nm
both are there

Comes with Android NDK allows you to dump the ELF dependencies of a given ELF shared library or executable.

Advertisements

AOSP change default time zone

android default time zone

https://stackoverflow.com/questions/22930726/where-does-android-take-default-timezone-from

getprop
set deafult timezone

getprop persist.sys.timezone
Asia/Shanghai

setprop persist.sys.timezone “Asia/Kolkata”

getprop persist.sys.timezone
Asia/Calcutta
shell@ASUS_Z010:/ $ setprop persist.sys.timezone “America/Chicago”

Even easier is to do from AOSP side is via
android/device//.mk

PRODUCT_PROPERTY_OVERRIDES += \
– persist.sys.timezone=Asia/Shanghai \
+ persist.sys.timezone=Asia/Kolkata \
persist.sys.country=US \
persist.sys.language=EN

adb launch any app

adb launch any app

like camera app
default if someone has already modified then it will launch their app

Image capture mode: adb shell “am start -a android.media.action.IMAGE_CAPTURE”

Video capture mode: adb shell “am start -a android.media.action.VIDEO_CAPTURE”

adb launch home app

am start -c android.intent.category.HOME -a android.intent.action.MAIN

or
am start -n com.android.launcher/com.android.launcher.Launcher
but I have already made my app as home so will not do

Start any app by just the package name

adb shell monkey -p app.package.name -c android.intent.category.LAUNCHER 1

monkey command

monkey -p com.nandan.mylauncher -c android.intent.category.LAUNCHER 1

Launch any app

com.vaultmicro.camerafi.apk

adb shell monkey -p app.package.name -c android.intent.category.LAUNCHER 1

adb shell monkey -p com.vaultmicro.camerafi -c android.intent.category.LAUNCHER 1

monkey -p com.vaultmicro.camerafi -c android.intent.category.LAUNCHER 1

am start -n com.nandan.myapp/.MyCustomAppActivity

Grant revoke permission

abd shell pm [grant|revoke] com.my.app android.permission.ACCESS_FINE_LOCATION

pm grant com.vaultmicro.camerafi android.permission.CAMERA

Starting a service from activity[same app]

Starting a service from activity[same app]
Activity.java


Intent it = new Intent(context, YourIntentService.class);
it.putExtra("Key", "Value");
startService(it);

or context.startService(it)

Service.START_STICKY Service is restarted if it gets terminated. Intent data passed to the onStartCommand method is null. Used for services which manages their own state and do not depend on the Intent data.

YourIntentService.java

public YourIntentService() {
    super("YourIntentService");
}

Qt android calling from java to C++

From java to C++

First define a native function declaration inside java code.


public static native void setAction(int arg);
[\sourcecode]

This can be used for invoke function connection from java code in the form:


setAction(1234);
[\sourcecode]

This is all from java side since all the job is made from C++ side.


extern “C”
{

JNIEXPORT void JNICALL Java_com_cnx_eyerismain_MyCustomAppService_setAction(JNIEnv env, jobject obj, jint action)
{
qDebug()<<"****** eyeris_main onReceiveAction"<<action;
// call MainWindow::onReceiveMounted from Qt thread

qDebug()<<"can tell here that message is received "<<action;
globalIsNewAction = true;
globalCurrentAction = action;
}

}
[\sourcecode]