@Override public void onServiceConnected(final ComponentName className, IBinder service) { Log.d( PluginConstants.LOG_TAG, "Enter LiveViewService.ServiceConnection.onServiceConnected."); mLiveView = IPluginServiceV1.Stub.asInterface(service); // Init adapter LiveViewCallback lvCallback = new LiveViewCallback(); // Install plugin try { if (mLiveView != null) { // Register mPluginId = mLiveView.register(lvCallback, mMenuIcon, mPluginName, false, getPackageName()); Log.d(PluginConstants.LOG_TAG, "Plugin registered with id: " + mPluginId); } } catch (RemoteException re) { Log.e(PluginConstants.LOG_TAG, "Failed to install plugin. Stop self."); stopSelf(); } Log.d(PluginConstants.LOG_TAG, "Plugin registered. mPluginId: " + mPluginId); }
public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Log.d(PluginConstants.LOG_TAG, "Enter LiveViewService.onStart."); if (intent.getBooleanExtra(INTENT_EXTRA_ANNOUNCE, false)) { Bundle extras = intent.getExtras(); if (extras != null) { try { if (mLiveView != null) { mLiveView.sendAnnounce( mPluginId, mMenuIcon, extras.getString(INTENT_EXTRA_TITLE), extras.getString(INTENT_EXTRA_TEXT), System.currentTimeMillis(), ""); Log.d(PluginConstants.LOG_TAG, "Announce sent to LiveView Application"); } else { Log.d(PluginConstants.LOG_TAG, "LiveView Application not reachable"); } } catch (Exception e) { Log.e(PluginConstants.LOG_TAG, "Failed to send announce", e); } } } else { // We end up here when LiveView Application probes the plugin if (isAlreadyRunning()) { Log.d(PluginConstants.LOG_TAG, "Already started."); } else { // Init mPluginName = PluginUtils.getDynamicResourceString(this, PluginConstants.RESOURCE_STRING_PLUGIN_NAME); // Bind to LiveView connectToLiveView(); // Singleton alreadyRunning = true; } } }