java - Run ContactsSyncAdapterService from outside Android app -
if app has exported service in android manifest means can run service within app right? illustration service looks in manifest file.
<service android:name=".account.contactsync.contactssyncadapterservice" android:exported="true" android:process=":contacts" > <intent-filter> <action android:name="android.content.syncadapter" /> </intent-filter> <meta-data android:name="android.content.syncadapter" android:resource="@xml/sync_contacts" /> <meta-data android:name="android.provider.contacts_structure" android:resource="@xml/contacts" /> </service>
as can see service set android:exported="true" means should able run outside of app right? how do that
i tried , didn't work
final intent intent = new intent(); componentname cname = new componentname ("com.myapp","com.myapp.contactssyncadapterservice"); intent.setcomponent(cname); startactivity(intent);
you're missing .account.contactsync
in component name:
componentname cname = new componentname("com.myapp", "com.myapp.account.contactsync.contactssyncadapterservice");
and you'd need utilize startservice()
instead of startactivity()
- startactivity()
starts activities.
java android android-intent android-syncadapter
No comments:
Post a Comment