Files
love-android/app/src/main/java/org/love2d/android/IntentReceiverActivity.java
T
Miku AuahDark 21a4c8eadc Impelement "Share to LOVE" support.
This allows you to share either .love game to launch as game (for the
non-fused APKs and instance of LOVE isn't running) or any file that
gets passed as love.filedropped.

Caveat: Ensure the intended game is running before sending files to LOVE app.
Otherwise, LOVE will attempt to open it as *.love file, which is may not what
you want.
2022-05-29 02:01:58 +08:00

29 lines
875 B
Java

package org.love2d.android;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.Nullable;
public class IntentReceiverActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent mainIntent = getIntent();
Intent intent = new Intent(this, GameActivity.class);
if (mainIntent.getAction().equals(Intent.ACTION_SEND)) {
// Convert to simpler intent that our GameActivity can process.
Uri uri = mainIntent.getParcelableExtra(Intent.EXTRA_STREAM);
intent.setData(uri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
startActivity(intent);
finish();
}
}