read

Base fix:

You need to add that IntentHelper.java to your project and edit some lines about intent creation for the LiveView base classes…
<ul><li>Update ‘connectToLiveView()’ in AbstractPluginService.java to:</li></ul><ol></ol><pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> /**
* Connects to the LiveView service.
*/
private void connectToLiveView() {
Intent baseIntent = new Intent(PluginConstants.LIVEVIEW_SERVICE_BIND_INTENT);
Intent explicitIntent = IntentHelper.createExplicitFromImplicitIntent(getApplicationContext(), baseIntent);
final boolean result = bindService(explicitIntent, mServiceConnection, 0);
if (result) {
Log.d(PluginConstants.LOG_TAG, "Bound to LiveView.");
} else {
Log.d(PluginConstants.LOG_TAG, "No bind.");
stopSelf();
}
}
</pre><ul><li>Update PluginReceiver.java onReceive() to:</li></ul><pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> public void onReceive(final Context context, final Intent intent) {
final String command = intent.getExtras().getString(PluginConstants.BROADCAST_COMMAND);
Log.d(PluginConstants.LOG_TAG, "Received command: " + command);
if (command == null) {
return;
}
if (command.contentEquals(PluginConstants.BROADCAST_COMMAND_PREFERENCES)) {
final String pluginName = intent.getExtras().getString(PluginConstants.BROADCAST_COMMAND_PLUGIN_NAME);
final String myPluginName = PluginUtils.getDynamicResourceString(context, PluginConstants.RESOURCE_STRING_PLUGIN_NAME);
if (pluginName != null && pluginName.contentEquals(myPluginName)) {
final String intentString = PluginUtils.getDynamicResourceString(context, PluginConstants.RESOURCE_STRING_INTENT_PREFS);
Log.d(PluginConstants.LOG_TAG, "Starting preferences! Intent: " + intentString);
final Intent prefsIntent = new Intent(intentString);
prefsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(prefsIntent);
}
} else if (command.contentEquals(PluginConstants.BROADCAST_COMMAND_START)) {
if (AbstractPluginService.isAlreadyRunning()) {
Log.d(PluginConstants.LOG_TAG, "Service is already running.");
} else {
final String serviceIntent = PluginUtils.getDynamicResourceString(context, PluginConstants.RESOURCE_STRING_INTENT_SERVICE);
Log.d(PluginConstants.LOG_TAG, "Starting service! Intent: " + serviceIntent);
Intent service = IntentHelper.createExplicitFromImplicitIntent(context, new Intent(serviceIntent));
context.startService(service);

}
}
}
</pre>

And now it should work :D

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview