I have got a simple aidl interface working:
package local.test;
interface ITest {
int[] getSupportedAidlLevels();
}
However I am struggling to pass the non primitive type android.nfc.Tag which already implements parcelable.
package local.test;
interface ITest {
int[] getSupportedAidlLevels();
void updateNfcTag(Tag tag);
}
I have tried to use an import statement like I would in java. Further I tried to create a second .aidl file like the following but non of this solved my problem.
package local.test;
import android.nfc.Tag;
parcelable Tag;
After a lot of trial and error I finally found the mistake. The in tag was missing.
package local.test;
interface ITest {
int[] getSupportedAidlLevels();
void updateNfcTag(in Tag tag);
}
Maybe this answer helps someone else ;)
Related
When compiling the following example from the robolectric migration guide
package com.jongla.soundmash.robolectric
import org.robolectric.shadows.ShadowApplicationPackageManager
import org.robolectric.annotation.Implements
import android.app.ApplicationPackageManager
#Implements(value = ApplicationPackageManager.class, inheritImplementationMethods = true)
class MyCustomPackageManager extends ShadowApplicationPackageManager {
}
AndroidStudio is giving me Unresolved reference: ApplicationPackageManager. Does anyone know what I need to do to get this example to compile? Do I need some additional testCompile package in gradle?
When I was looking through Roboloectric source code, I ve spotted attribute className to specify class name instead. And it works like magic.
#Implements(className = "android.app.ApplicationPackageManager", inheritImplementationMethods = true)
public class MyCustomPackageManager extends ShadowApplicationPackageManager {
}
Migration document is clearly incorrect, when suggesting to use value as ApplicationPackageManager class is private and not visible for user code.
I have an aidl file:
package com.xyz;
interface ICallback
{
void CallbackMsg(String type, String value1);
}
I have another aidl file:
package com.xyz;
import com.xyz.ICallback;
interface ISendMsg
{
int getPid();
void SendMsg(String value1);
void registerCallBack(ICallback cb);
void unregisterCallBack(ICallback cb);
}
It gives error as: couldn't find import for class com.xyz.ICallback
What am i doing wrong?
I was copy pasting aidl files from other source and thats why it created a problem.
Once I created the aidl files in the project itself, it stopped giving errors?
I have an Android application.
I want to scan for all classes within a package for a specify annotation.
I have:
package com.sample.package;
import com.sample.core.Controller;
import com.sample.core.ProtocolId;
#Controller
public class OtherController implements ControllerInterface{
#ProtocolId(id=100)
public void doSomething(){
//do something
}
}
I'm finding for classes annotated with #Controller for a specify #ProtocolId number.
I'm using Google Reflections library.
Here is how I'm scanning:
package com.sample.package;
import org.reflections.ReflectionUtils;
import org.reflections.Reflections;
import com.sample.core.Controller;
import com.sample.core.ProtocolId;
public class FrontController {
public void executeProperControllerMethodBasedOnId(){
Reflections ref = new Reflections("com.sample.package");
Set<Class<?>> classes = ref.getTypesAnnotatedWith(Controller.class);
System.out.println(classes.size()); //THE SIZE IS 0!!!
//The reflection doesn't worked! It didn't found any class!
}
}
The above code doesn't find any class annotated with specify annotation. Is
there something which I miss when I'm using google reflection library on
android?
I was trying to test activity lifecycle of an application(testbuild). As i start writing testcase class, i am getting errors in the class declaration that "testbuild" cannot be resolved to a type. Please someone fix this.
package com.example.testbuild.test;
import android.test.ActivityInstrumentationTestCase2;
import com.example.testbuild.*;
public class second extends ActivityInstrumentationTestCase2<testbuild>
{
}
Instead of testbuild you must use testable activity:
public class second extends ActivityInstrumentationTestCase2<YourActivity>
{
//...
}
I am creating an AIDL interface that uses an object type from an android library that is part of a different project. I can import and use the type fine in my service, but I can not import it in my AIDL interface.
package com.mysite.service;
import com.othersite.library.MyObject;
interface IMyService {
int getPid();
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
MyObject getObjects();
}
The error is:
couldn't find import for class com.othersite.library.MyObject
You must create a separate .aidl file for each class you wish to use
within your service that declares that class as parcelable.
There is a blog post about this issue here.