Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None of "Open Source App" working #1056

Open
peterweb2005 opened this issue Jan 18, 2021 · 2 comments
Open

None of "Open Source App" working #1056

peterweb2005 opened this issue Jan 18, 2021 · 2 comments

Comments

@peterweb2005
Copy link

peterweb2005 commented Jan 18, 2021

as title

https://github.com/jondot/awesome-react-native#open-source-apps

it is not possible to find a worked sample react native app,
even not with expo, which is more than 2 years ago

@miniyarov
Copy link
Contributor

I recently published an open source app to App Store, I hope this helps.
https://github.com/zudvpn/ZudVPN
https://apps.apple.com/us/app/zudvpn-personal-vpn-on-cloud/id1517610454

@johnpawl
Copy link

Help !!!

I want to get back to android activity from react-native activity using backkey .

MainActivity.java

public class MainActivity extends AppCompatActivity {

Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startRNPage();
        }
    });
}

private void startRNPage() {
    Intent intent = new Intent(this, ReactNativeActivity.class);
    startActivity(intent);
    finish();
}
}

ReactNativeActivity.java

public class ReactNativeActivity extends AppCompatActivity {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SoLoader.init(this, false);

    mReactRootView = new ReactRootView(this);
    List<ReactPackage> packages = new PackageList(getApplication()).getPackages();
    // Packages that cannot be autolinked yet can be added manually here, for example:
    // packages.add(new MyReactNativePackage());
    // Remember to include them in `settings.gradle` and `app/build.gradle` too.

    

    mReactInstanceManager = ReactInstanceManager.builder()
    .setApplication(getApplication())
    .setCurrentActivity(this)
    .setBundleAssetName("index.android.bundle")
    .setJSMainModulePath("index")
    .addPackages(packages)
    .setUseDeveloperSupport(BuildConfig.DEBUG)
    .setInitialLifecycleState(LifecycleState.RESUMED)
    .build();
    // The string here (e.g. "MyReactNativeApp") has to match
    // the string in AppRegistry.registerComponent() in index.js
    mReactRootView.startReactApplication(mReactInstanceManager, "firstpro", null);

    setContentView(mReactRootView);
    }
@Override
public void onBackPressed() {
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onBackPressed();
    } else {
      super.onBackPressed();
    }
}
}

I also tried the following code in ReactNativeActivity.java

public void onBackPressed() {
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onBackPressed();
    } else {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }
}

If I pressed the back button it didn't get back to android activity.

How can I get back to android activity from react-native activity using backkey?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants