Skip to content

Commit 8a81f56

Browse files
committed
Android 10対応(Activity起動方法の修正) 追加
1 parent b187aa4 commit 8a81f56

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/recorder/screen

dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/recorder/screen/ScreenCastManager.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
import android.media.ImageReader;
99
import android.media.projection.MediaProjection;
1010
import android.media.projection.MediaProjectionManager;
11+
import android.os.Build;
1112
import android.os.Bundle;
1213
import android.os.Handler;
1314
import android.os.Looper;
1415
import android.os.ResultReceiver;
1516
import android.view.Surface;
1617

1718
import org.deviceconnect.android.deviceplugin.host.recorder.HostDeviceRecorder;
19+
import org.deviceconnect.android.util.NotificationUtils;
1820

1921
@TargetApi(21)
2022
class ScreenCastManager {
@@ -31,6 +33,13 @@ class ScreenCastManager {
3133

3234
private final Handler mCallbackHandler = new Handler(Looper.getMainLooper());
3335

36+
/** Notification Id */
37+
private final int NOTIFICATION_ID = 3539;
38+
39+
/** Notification Content */
40+
private final String NOTIFICATION_CONTENT = "Host Media Streaming Recording Profileからの起動要求";
41+
42+
3443
ScreenCastManager(final Context context) {
3544
mContext = context;
3645
mMediaProjectionMgr = (MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
@@ -76,7 +85,12 @@ public void onStop() {
7685
}
7786
}
7887
});
79-
mContext.startActivity(intent);
88+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
89+
mContext.startActivity(intent);
90+
} else {
91+
NotificationUtils.createNotificationChannel(mContext);
92+
NotificationUtils.notify(mContext, NOTIFICATION_ID, 0, intent, NOTIFICATION_CONTENT);
93+
}
8094
}
8195

8296
public SurfaceScreenCast createScreenCast(final Surface outputSurface, final HostDeviceRecorder.PictureSize size) {

0 commit comments

Comments
 (0)