tencent cloud

문서Cloud Application RenderingPractical TutorialCloud APK Parameter Transfer Description

Cloud APK Parameter Transfer Description

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-07-09 16:06:17
To support parameter passing, the cloud APK application needs to be modified accordingly to respond to the relevant parameters.

Parameter Transfer Methods

When calling the cloud rendering CreateSession API, you must enter the information in the ApplicationParams parameter in a fixed format.
--es key value
Format Description:
Separate the three fields --es, key, and value with a space.
This parameter is passed to the client container along with the task.
Example:
--es ParamKey {value1,value2} xxx

Parameter Reception and Acquisition Process

1. Broadcast Triggering

After a cloud rendering task is initiated, the cloud Android container automatically brings the business App to the foreground and broadcasts a message.
android.intent.action.CLOUD_GAMING_STARTED

2. Reception and Parsing

The business APK must register this broadcast in MainActivity. After the broadcast is received, you can obtain the data using the following methods:
String data = intent.getStringExtra("key");
Example Note:
Parameter Passed
Obtaining Method
Final Value
--es ParamKey {value1,value2} xxx
intent.getStringExtra("ParamKey")
{value1,value2} xxx
After the data is obtained, the business APK can perform business processing based on this parameter, such as redirecting to a live streaming room.

Local Testing Methods

After the broadcast registration for the business APK is completed, you can use the following 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

Core Implementation Recommendations

1. Creating a Broadcast Receiver

You need to create a BroadcastReceiver class to listen for the android.intent.action.CLOUD_GAMING_STARTED broadcast and extract the carried extra data via intent.getExtras().

2. Dynamic Registration

Dynamically register this Receiver in MainActivity or Service to ensure it correctly responds to and parses parameters when the container is started.

Complete Sample Code

1. Broadcast Receiver Handler Class

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";

@Override
public 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.");
}
}
}

2. Dynamically Registering in an Activity

import android.content.IntentFilter;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
private CloudGamingBroadcastReceiver receiver;

@Override
protected 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);
}

@Override
protected void onDestroy() {
super.onDestroy();
// Unregister the broadcast receiver to prevent memory leaks.
if (receiver != null) {
unregisterReceiver(receiver);
}
}
}

3. Key Notes

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

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백