mirror of
https://github.com/love2d/love-android.git
synced 2026-08-14 01:20:55 +02:00
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.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user