Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get blank activity opened when starting new activity

I am using this library for multiple image selection. After the user finish selecting the photos, another activity (current_location.class) should start.

Here is my code to do that:

public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == OPEN_MEDIA_PICKER) {
            // Make sure the request was successful
            if (resultCode == RESULT_OK && data != null) {
                selectionResult = data.getStringArrayListExtra("result");
                Intent intent = new Intent(getActivity(), currentLocation.class);
                intent.putExtra("selectedMedia", selectionResult);
                startActivity(intent);
            }
        }
    }

new activity is successfully started but its blank!

Below is my currentLocation.java Activity:

public class currentLocation extends AppCompatActivity {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.current_location);
    }
}

and here is the current_location.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_view">
    
</android.support.constraint.ConstraintLayout>

it should have background color, I tried adding buttons as well, but I always get blank activity started

is the problem from the way I am starting new activity? or from the way I am setting the xml layout to the currentLocation class?

like image 732
Source Avatar asked Dec 21 '25 14:12

Source


1 Answers

try changing your onCreate method. use the following instead:

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.current_location);
    }
like image 138
Behrouz Riahi Avatar answered Dec 24 '25 05:12

Behrouz Riahi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!