missing com.android.nfc.cardemulation.HostEmulationManager in android.jar - android

I want to debug my HostCardEmulation App in eclipse. To see which select AID command is send from the reader, I want to step into Android source code: but I can't find com.android.nfc.cardemulation.HostEmulationManager.java (class) in android.jar.

This class is not part of the Android framework (i.e. the classes that comprise the Android API). Instead it is part of the Android NFC system service (the system component that manages the NFC stack). The NFC service and your apps (through the framework classes) communicate through IPC techniques. Hence, there is no need (from an SDK perspective) to have the source code of such system services.
Consequently, this class is not "missing" but it is simply not supposed to be part of the Android SDK (android.jar) as the SDK only contains the framework classes (i.e. the classes that your apps can be compiled against). You can still get its source code from the AOSP project: packages/apps/Nfc.

Related

Creating android application without Android framework

In Android Stack 4th Layer is android Framework which uses JAVA,Kotlin. If I am correct than all applications are made from this framework.
Is there some other non JVM-Language based framework from which I can made Android Apps ?
I tried QT, But It also creates some java files and uses android Framework. Is it even possible to make Android app WITHOUT EVEN ANY PRESENCE OF JAVA ?
If your objective is to simply not write in a JVM language, you are welcome to use C/C++ with the NDK, using NativeActivity as your entry point.
If your objective is to avoid the framework classes entirely, you are welcome to build your own fork of Android that contains your own code as native Linux daemons, launched by init scripts or something.
If your objective is to ship an app on the Play Store or through similar channels that avoids the framework classes entirely, AFAIK there is no option for that.
You can not create an android application without using android framework. At least, for launching your application you will have to use framework functions from "android.os" package.

Create SDK (or Library) from existing Android App (APK) that can be included in other Android Apps

I have an existing Android App that we now want to leverage as an SDK (or whatever is the equivalent on Android, a library?), so that the application could be included in another Android App as a library.
The concept is that we provide a "wrapper" class that customers make calls to, which would then interface with the existing code to do the functions, display stuff and do the work our App generally does.
My hope is to be able to not have to move code around and just create a wrapper/SDK/Library interface which I can just build differently in gradle, and the result of that (a Library object?) would be given to the customer to include into their App.
Hope I am making sense. If you need more info I can give a high level example of what the App is doing.

How to Create a android native service and use binder to communicate with it?

My basic task is to create a native service in android and then write a simple native program to test it. lets say I want to write a simple service which return me sum of two integers. I have to use binders to talk to it from the program, I have tried to google around but I can't find a precise example. I need to know how to create a native service and find it in the program and if needed in Java also.
If you're creating a normal Android application using the NDK, you can't use Binder because it's not part of the NDK APIs.
Look in the NDK docs/STABLE-APIS.html for the full list of stable APIs, and this thread for an explicit comment by David Turner (the NDK maintainer) that Binder is not a supported API.
https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/1QmVRrNckfM
Your options are:
Use some other form of IPC in native code - for example a UNIX domain socket
Do it in Java, using the normal Service and AIDL facilities of the Android SDK. If you wish to combine this with native code you may be able to call up to Java from native code using JNI.
(Not recommended) Copy the relevant libraries and headers from an Android Open-Source Project; build into your NDK project; and use the APIs. However this is not officially supported and is extremely likely to break your application in future releases because Google are under no obligation to maintain compatibility in such libraries (and frequently do not). It's also very difficult, since you need to find some way to register the service such that the client can find it.
The solution that I found is to use the Binders in native and use the
defaultServiceManager()->addService(
String16("TestService"),new CalcService());
and then use binders and use following on client side.
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16("TestService"));
I found examples here on how to do this:
https://github.com/gburca/BinderDemo/blob/master/binder.cpp
After studying and coding # Android NDK, I found The binder API is NOT available in Android NDK.
And even if you use android open source for invoking the binder api, maybe you will get permission denied because of the binder security checking.
Here if I want to add a service to System service, I need a system level user group. The detail codes you can find https://github.com/qianjigui/android_system_service_example. It contains C and Java level's client and service, but you need the system permission.

Android API from Go

I know that Go programs can be compiled for Android.
How can I use Android specific API, like getting GPS coordinates or opening a URL with the default browser, from within a Go program?
I'm afraid it's hardly possible at the moment. In the "Meet the Go Team" I/O sessions, the guys from the Go team stated that they have no plans to add Android support to Go.
What we have now is just a compiler for ARM architecture. Unfortunately, this is pretty much useless for real Android apps, though such programs can be launched from the command line on Android devices.
Most of the Android framework is written in Java, so to interact with it your code should be compiled to a *.so libary, that will be loaded and called via the JNI interface. And it's not possible with the current Go compiler (gc, not sure about the gccgo).
Maybe you will be able to make bindings to the Android NDK API with cgo, that would allow you to create applications in Go since API level 9 (Android 2.3)
UPD: You can now use JNI from Go and create java bindings automatically with golang.org/x/mobile package. In Go 1.4 it's still experimental, but there are plans to include it into Go 1.5 release. The package also provides bindings for GL, audio and user input (hopefully they would also add iOS support and that would be compatible for Android and iOS one day). Anyway this package is mostly oriented at writing games in Go, rather than using Go as a replacement for Java on Android.
Take a look at my answer to Android App from Go programming language. The goandroid project allows you to create Android apps in Go through the NDK.
(Disclaimer: I'm the author of goandroid)
Edit: As mentioned in the comments, Go 1.5 adds official support for Android apps in pure Go or as a mix of Java and Go. iOS is also expected to arrive in time for the final 1.5 release. See https://github.com/golang/mobile for more details.
GO 1.4 doc says, "Go 1.4 can build binaries for ARM processors running the Android operating system. It can also build a .so library that can be loaded by an Android application using the supporting packages in the mobile subrepository"
There is package app option in "golang.org/x/mobile/app" library that lets you write Apps for Android (and eventually, iOS).
Step 1: Create a platform independent GUI library using Golang that uses OpenGL to draw and an intelligent event and data-binding system to write the apps in. Any software using OpenGL is going to be more-or-less portable. Essentially, re-write Kivy in Golang.
Step 2: Create introspection/reflection based wrapper for using Java classes similar to PyJNIus (also a Kivy project).
Step 3: Lots more hard work, because there is a lot to do to get to the level of Kivy
Step 4: Profit

Android architecture

Now I am doing an android project(Api level 8),I install JD-Eclipse(decompiler) to know the flow of program execution.The decompiled 'android.jar' contains full of abstract classes and interfaces, then where is the actual class containing the body to be executed? What is the name of that jar file?
You probably won't find what you are looking for. The android.jar is an API and as that not directly executable, there isn't even any guarantee that it contains such code.
If you want to start creating an application, just go to the developer page and start reading through the documentation on how to set up the development environment, how to program against the API, how to test your application and, finally, how to deploy it on an actual device.
The lifecycle of an activity for example can be found in the documentation.
Android.jar contains the Android API (Classes, interfaces, ..). If you want to see the rest, download the source from Android Git repository or via SDK Manager.

Categories

Resources