Error calling Android activity from .aar library. -
i have project uses googles map api performs geofencing , other map related activities. transformed project library (.aar) can share other projects has similar use cases maps , geofnece.
my problem when create new project , import .aar library cannot call activities inside .aar library.
app crashers after click button call activity library , shows error in debugger.
android.content.activitynotfoundexception: no activity found handle intent { act=com.package.name.mapsactivity }
this how call activity
public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } //onclick button public void testsubmit(view view) { //com.package.name.mapactivity activity inside .aar intent intent = new intent("com.package.name.mapsactivity"); startactivity(intent); } }
i added activity projects manifest after imported .aar
<activity android:name=".mainactivity" > <intent-filter> <action android:name="android.intent.action.main" /> <activity android:name="com.package.name.mapsactivity" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
try this:
intent intent = new intent(android.content.intent.action_view); intent.setcomponent(new componentname("packagename//com.package.name, "classname//com.package.name.mapsactivity")); startactivity(intent);
answer here https://stackoverflow.com/a/9822278/4848308
Comments
Post a Comment