添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Access onCreate() Lifecycle in Cordova plugin #1202

Closed
@hug0b

Description

Feature Request

Motivation Behind Feature

Some plugins may require to perform actions inside the onCreate() Activity Lifecycle.

An example of logic that needs to be inside onCreate :

public class MainActivity extends AppCompatActivity {
  private Foo mService;
  private ServiceConnection mConnection;
  private boolean isConnect = false;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
     if(mConnection == null)
        mConnection = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName className, IBinder service) {
                mService = Foo.bar(service);
                isConnect = true;

In my understanding onServiceConnected should have ran when onCreate has completed.
This logic would not behave the same inside the available CordovaPlugin class methods like initialize() or onStart().

(My real world use case is to write a Cordova plugin for the MCOP SDK).

Feature Description

From a Cordova plugin, we should be able to hook inside Cordova's MainActivity onCreate. (We can currently inject code in Cordova's Activity but it can't be linked to plugin code afaik).

From my current Cordova knowledge I am unsure how it could be implemented.

Alternatives or Workarounds

I have not found any so far.