CreateSession API, you must enter the information in the ApplicationParams parameter in a fixed format.--es key value
--es, key, and value with a space.--es ParamKey {value1,value2} xxx
android.intent.action.CLOUD_GAMING_STARTED
MainActivity. After the broadcast is received, you can obtain the data using the following methods:String data = intent.getStringExtra("key");
Parameter Passed | Obtaining Method | Final Value |
--es ParamKey {value1,value2} xxx | intent.getStringExtra("ParamKey") | {value1,value2} xxx |
adb command to locally simulate and test whether the redirection feature works properly:adb shell am broadcast -a android.intent.action.CLOUD_GAMING_STARTED -e tencent_scheme Tencent://autoAuth
BroadcastReceiver class to listen for the android.intent.action.CLOUD_GAMING_STARTED broadcast and extract the carried extra data via intent.getExtras().MainActivity or Service to ensure it correctly responds to and parses parameters when the container is started.import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.util.Log;import android.os.Bundle;public class CloudGamingBroadcastReceiver extends BroadcastReceiver {private static final String TAG = "CloudGamingReceiver";@Overridepublic void onReceive(Context context, Intent intent) {// Check whether the broadcast Action matches the target.if (intent == null || !"android.intent.action.CLOUD_GAMING_STARTED".equals(intent.getAction())) {return;}// Print the complete broadcast information (including extra data).Log.d(TAG, "Received CLOUD_GAMING_STARTED broadcast, source: " + intent.getSourceFilters());// Extract the extra data carried by the broadcast (adjust the key name according to the actual scenario).Bundle extras = intent.getExtras();if (extras != null) {Log.d(TAG, "Extra data carried by the broadcast: ");for (String key : extras.keySet()) {Object value = extras.get(key);Log.d(TAG, " Key: " + key + ", Value: " + value);}} else {Log.d(TAG, "The broadcast does not carry extra data.");}}}
import android.content.IntentFilter;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;public class MainActivity extends AppCompatActivity {private CloudGamingBroadcastReceiver receiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// Instantiate the broadcast receiver.receiver = new CloudGamingBroadcastReceiver();// Create an IntentFilter and add the Action.IntentFilter filter = new IntentFilter();filter.addAction("android.intent.action.CLOUD_GAMING_STARTED");// Dynamically register the broadcast receiver.registerReceiver(receiver, filter);}@Overrideprotected void onDestroy() {super.onDestroy();// Unregister the broadcast receiver to prevent memory leaks.if (receiver != null) {unregisterReceiver(receiver);}}}
Project | Description |
Feature | Works with the parameters passed when a cloud rendering task is initiated. After the business APK is launched by the cloud rendering Android container, it automatically receives broadcasts and parses the parameters. |
Broadcast Action | android.intent.action.CLOUD_GAMING_STARTED |
Parameter Format | --es key value |
Local Test Command | adb shell am broadcast -a android.intent.action.CLOUD_GAMING_STARTED -e tencent_scheme Tencent://autoAuth |
피드백