Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Notice removed Draw attention by Community Bot
Bounty Ended with no winning answer by Community Bot
Notice added Draw attention by Barry B Benson
Bounty Started worth 300 reputation by Barry B Benson
removed deprecated tag
Source Link

newNew to androidAndroid development, I have made an app (the server) in android studioAndroid Studio, and I have made a simple plugin in civTAK (client). To put simply, my app is proprietary, so I can't expose or share the package/module of the app. So I came up with the slutionsolution to make a new library which will contain the aidl information, e.g., "aidlinterface" with the package name com.aidlinterface, and then add that to the app level gradle for both server and client apps.

startService(Intent(this, ServiceName::class.java))

startService(Intent(this, ServiceName::class.java))

And for the purposes of this example we can say that the service only has a log statement that says "service initialised". But, but when I go on logcat and filter by com.aidlinterface, nothing is showing up, which tells me that the package is not attached. but I have added the package in:

// IAIDLColorInterface.aidl
package com.aidlinterface;
// Declare any non-default types here with import statements
interface IAIDLColorInterface {
 /**
 * Demonstrates some basic types that you can use as parameters
 * and return values in AIDL.
 */
 int getColor();
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:label="@string/app_name"
 android:supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:label="@string/app_name"
 android:supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>
<civTAK imports>
import com.aidlinterface.IAIDLColorInterface
class ColorPlugin(
mapView:MapView ){
private var AIDLColorService: IAIDLColorInterface? = null
private val serviceConnection = object: ServiceConnection {
 override fun onServiceConnected(name: ComponentName?, service:IBinder?){
 AIDLColorService = IAIDLColorInterface.Stub.asInterface(service)
 }
 override fun onServiceDisconnected(name: ComponentName?){
 AIDLColorService = null
 }
 init{
 val serviceIntent = Intent("AIDLColorService")
 serviceIntent.setPackage("com.aidlInterface")
 pluginContext.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
 override fun disposeImpl(){
 pluginContext.unbindService(serviceConnection)
 }
 override fun onReceive(context:Context, intent: Intent){
 // code for plugin
 // CODE THAT CALLS SERVICE
 b.setOnClickListener {
 try {
 val color = iADILColorService.color
 it.setBackgroundColor(color)
 } catch (e: RemoteException) {
 // Handle exception
 }
}
}

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Thank you!

new to android development, I have made an app (the server) in android studio, and I have made a simple plugin in civTAK (client). To put simply, my app is proprietary, so I can't expose or share the package/module of the app. So I came up with the slution to make a new library which will contain the aidl information, e.g., "aidlinterface" with the package name com.aidlinterface, and then add that to the app level gradle for both server and client apps.

startService(Intent(this, ServiceName::class.java))

And for the purposes of this example we can say that the service only has a log statement that says "service initialised". But when I go on logcat and filter by com.aidlinterface, nothing is showing up, which tells me that the package is not attached. but I have added the package in:

// IAIDLColorInterface.aidl
package com.aidlinterface;
// Declare any non-default types here with import statements
interface IAIDLColorInterface {
 /**
 * Demonstrates some basic types that you can use as parameters
 * and return values in AIDL.
 */
 int getColor();
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:label="@string/app_name"
 android:supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>
<civTAK imports>
import com.aidlinterface.IAIDLColorInterface
class ColorPlugin(
mapView:MapView ){
private var AIDLColorService: IAIDLColorInterface? = null
private val serviceConnection = object: ServiceConnection {
 override fun onServiceConnected(name: ComponentName?, service:IBinder?){
 AIDLColorService = IAIDLColorInterface.Stub.asInterface(service)
 }
 override fun onServiceDisconnected(name: ComponentName?){
 AIDLColorService = null
 }
 init{
 val serviceIntent = Intent("AIDLColorService")
 serviceIntent.setPackage("com.aidlInterface")
 pluginContext.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
 override fun disposeImpl(){
 pluginContext.unbindService(serviceConnection)
 }
 override fun onReceive(context:Context, intent: Intent){
 // code for plugin
 // CODE THAT CALLS SERVICE
 b.setOnClickListener {
 try {
 val color = iADILColorService.color
 it.setBackgroundColor(color)
 } catch (e: RemoteException) {
 // Handle exception
 }
}
}

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Thank you!

New to Android development, I have made an app (the server) in Android Studio, and I have made a simple plugin in civTAK (client). To put simply, my app is proprietary, so I can't expose or share the package/module of the app. So I came up with the solution to make a new library which will contain the aidl information, e.g., "aidlinterface" with the package name com.aidlinterface, and then add that to the app level gradle for both server and client apps.

startService(Intent(this, ServiceName::class.java))

And for the purposes of this example we can say that the service only has a log statement that says "service initialised", but when I go on logcat and filter by com.aidlinterface, nothing is showing up, which tells me that the package is not attached. but I have added the package in:

// IAIDLColorInterface.aidl
package com.aidlinterface;
// Declare any non-default types here with import statements
interface IAIDLColorInterface {
 /**
 * Demonstrates some basic types that you can use as parameters
 * and return values in AIDL.
 */
 int getColor();
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:label="@string/app_name"
 android:supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>
<civTAK imports>
import com.aidlinterface.IAIDLColorInterface
class ColorPlugin(
mapView:MapView ){
private var AIDLColorService: IAIDLColorInterface? = null
private val serviceConnection = object: ServiceConnection {
 override fun onServiceConnected(name: ComponentName?, service:IBinder?){
 AIDLColorService = IAIDLColorInterface.Stub.asInterface(service)
 }
 override fun onServiceDisconnected(name: ComponentName?){
 AIDLColorService = null
 }
 init{
 val serviceIntent = Intent("AIDLColorService")
 serviceIntent.setPackage("com.aidlInterface")
 pluginContext.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
 override fun disposeImpl(){
 pluginContext.unbindService(serviceConnection)
 }
 override fun onReceive(context:Context, intent: Intent){
 // code for plugin
 // CODE THAT CALLS SERVICE
 b.setOnClickListener {
 try {
 val color = iADILColorService.color
 it.setBackgroundColor(color)
 } catch (e: RemoteException) {
 // Handle exception
 }
}
}

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Made the question a minimum reproducible example
Source Link

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.tollcafe.aidlserver">android">
 <application
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:roundIcon="@mipmap/ic_launcher_round"
 android:supportsRtl="true"
 android:theme="@style/Theme.AIDLServer">supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.tollcafe.aidlserver">
 <application
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:roundIcon="@mipmap/ic_launcher_round"
 android:supportsRtl="true"
 android:theme="@style/Theme.AIDLServer">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <application
 android:label="@string/app_name"
 android:supportsRtl="true">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>
Made the question a minimum reproducible example
Source Link

Here is the AIDL interface:


// IAIDLColorInterface.aidl
package com.aidlinterface;
// Declare any non-default types here with import statements
interface IAIDLColorInterface {
 /**
 * Demonstrates some basic types that you can use as parameters
 * and return values in AIDL.
 */
 int getColor();
}

The same interface is present in the client app library.

Here is the service in the server app:

package com.aidlinterface;
import android.app.Service;
import android.content.Intent;
import android.graphics.Color;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import java.util.Random;
public class AIDLColorService extends Service {
 private static final String TAG ="AIDLColorService" ;
 public AIDLColorService() {
 }
 @Override
 public IBinder onBind(Intent intent) {
 // TODO: Return the communication channel to the service.
 return binder;
 }
 private final IAIDLColorInterface.Stub binder = new IAIDLColorInterface.Stub() {
 @Override
 public int getColor() throws RemoteException {
 Random rnd = new Random();
 int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
 Log.d(TAG, "getColor: "+ color);
 return color;
 }
 };
}

The manifest for the server app's aidlInterface library:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.tollcafe.aidlserver">
 <application
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:roundIcon="@mipmap/ic_launcher_round"
 android:supportsRtl="true"
 android:theme="@style/Theme.AIDLServer">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>

Here is the code from the client app where I am using this information:

<civTAK imports>
import com.aidlinterface.IAIDLColorInterface
class ColorPlugin(
mapView:MapView ){
private var AIDLColorService: IAIDLColorInterface? = null
private val serviceConnection = object: ServiceConnection {
 override fun onServiceConnected(name: ComponentName?, service:IBinder?){
 AIDLColorService = IAIDLColorInterface.Stub.asInterface(service)
 }
 override fun onServiceDisconnected(name: ComponentName?){
 AIDLColorService = null
 }
 init{
 val serviceIntent = Intent("AIDLColorService")
 serviceIntent.setPackage("com.aidlInterface")
 pluginContext.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
 override fun disposeImpl(){
 pluginContext.unbindService(serviceConnection)
 }
 override fun onReceive(context:Context, intent: Intent){
 // code for plugin
 // CODE THAT CALLS SERVICE
 b.setOnClickListener {
 try {
 val color = iADILColorService.color
 it.setBackgroundColor(color)
 } catch (e: RemoteException) {
 // Handle exception
 }
}
}

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Here is the AIDL interface:


// IAIDLColorInterface.aidl
package com.aidlinterface;
// Declare any non-default types here with import statements
interface IAIDLColorInterface {
 /**
 * Demonstrates some basic types that you can use as parameters
 * and return values in AIDL.
 */
 int getColor();
}

The same interface is present in the client app library.

Here is the service in the server app:

package com.aidlinterface;
import android.app.Service;
import android.content.Intent;
import android.graphics.Color;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import java.util.Random;
public class AIDLColorService extends Service {
 private static final String TAG ="AIDLColorService" ;
 public AIDLColorService() {
 }
 @Override
 public IBinder onBind(Intent intent) {
 // TODO: Return the communication channel to the service.
 return binder;
 }
 private final IAIDLColorInterface.Stub binder = new IAIDLColorInterface.Stub() {
 @Override
 public int getColor() throws RemoteException {
 Random rnd = new Random();
 int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
 Log.d(TAG, "getColor: "+ color);
 return color;
 }
 };
}

The manifest for the server app's aidlInterface library:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.tollcafe.aidlserver">
 <application
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:roundIcon="@mipmap/ic_launcher_round"
 android:supportsRtl="true"
 android:theme="@style/Theme.AIDLServer">
 <service
 android:name=".AIDLColorService"
 android:enabled="true"
 android:exported="true">
 <intent-filter>
 <action android:name="AIDLColorService" />
 </intent-filter>
 </service>
 </application>
</manifest>

Here is the code from the client app where I am using this information:

<civTAK imports>
import com.aidlinterface.IAIDLColorInterface
class ColorPlugin(
mapView:MapView ){
private var AIDLColorService: IAIDLColorInterface? = null
private val serviceConnection = object: ServiceConnection {
 override fun onServiceConnected(name: ComponentName?, service:IBinder?){
 AIDLColorService = IAIDLColorInterface.Stub.asInterface(service)
 }
 override fun onServiceDisconnected(name: ComponentName?){
 AIDLColorService = null
 }
 init{
 val serviceIntent = Intent("AIDLColorService")
 serviceIntent.setPackage("com.aidlInterface")
 pluginContext.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
 override fun disposeImpl(){
 pluginContext.unbindService(serviceConnection)
 }
 override fun onReceive(context:Context, intent: Intent){
 // code for plugin
 // CODE THAT CALLS SERVICE
 b.setOnClickListener {
 try {
 val color = iADILColorService.color
 it.setBackgroundColor(color)
 } catch (e: RemoteException) {
 // Handle exception
 }
}
}

Any advice on this will be greatly appreciated. I understand this is a very vague problem, but I will try to answer any questions as best as possible!

Source Link
Loading
default

AltStyle によって変換されたページ (->オリジナル) /