-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #391 from jinanzhuan/sdk3.0
adapter androidQ.
- Loading branch information
Showing
11 changed files
with
221 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
app/src/main/java/com/hyphenate/chatuidemo/conference/SRForegroundService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.hyphenate.chatuidemo.conference; | ||
|
||
import android.app.Notification; | ||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.app.PendingIntent; | ||
import android.app.Service; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.graphics.BitmapFactory; | ||
import android.media.projection.MediaProjection; | ||
import android.media.projection.MediaProjectionManager; | ||
import android.os.Build; | ||
import android.os.IBinder; | ||
import android.support.annotation.Nullable; | ||
import android.support.annotation.RequiresApi; | ||
|
||
import com.hyphenate.chatuidemo.R; | ||
import com.superrtc.mediamanager.ScreenCaptureManager; | ||
|
||
import java.util.Objects; | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) | ||
public class SRForegroundService extends Service { | ||
private int resultCode; | ||
private Intent resultData; | ||
private MediaProjectionManager projectionManager; | ||
private MediaProjection mMediaProjection; | ||
|
||
@Nullable | ||
@Override | ||
public IBinder onBind(Intent intent) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int onStartCommand(Intent intent, int flags, int startId) { | ||
//启动前置服务 | ||
createNotificationChannel(); | ||
resultCode = intent.getIntExtra("code", -1); | ||
resultData = intent.getParcelableExtra("data"); | ||
|
||
this.projectionManager = (MediaProjectionManager)getSystemService(Context.MEDIA_PROJECTION_SERVICE); | ||
mMediaProjection = projectionManager.getMediaProjection(resultCode, Objects.requireNonNull(resultData)); | ||
|
||
ScreenCaptureManager.getInstance().start(resultCode, resultData, mMediaProjection); | ||
return super.onStartCommand(intent, flags, startId); | ||
} | ||
|
||
private void createNotificationChannel() { | ||
Notification.Builder builder = new Notification.Builder(this.getApplicationContext()); //获取一个Notification构造器 | ||
Intent nfIntent = new Intent(this, ConferenceActivity.class); //点击后跳转的界面,可以设置跳转数据 | ||
|
||
builder.setContentIntent(PendingIntent.getActivity(this, 0, nfIntent, 0)) // 设置PendingIntent | ||
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.em_logo_uidemo)) // 设置下拉列表中的图标(大图标) | ||
//.setContentTitle("SMI InstantView") // 设置下拉列表里的标题 | ||
.setSmallIcon(R.drawable.em_logo_uidemo) // 设置状态栏内的小图标 | ||
.setContentText(getString(R.string.share_screen_ongoing)) // 设置上下文内容 | ||
.setWhen(System.currentTimeMillis()); // 设置该通知发生的时间 | ||
|
||
/*以下是对Android 8.0的适配*/ | ||
//普通notification适配 | ||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
builder.setChannelId("share_screen_id"); | ||
} | ||
//前台服务notification适配 | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); | ||
NotificationChannel channel = new NotificationChannel("share_screen_id", "shareScreen", NotificationManager.IMPORTANCE_LOW); | ||
notificationManager.createNotificationChannel(channel); | ||
} | ||
|
||
Notification notification = builder.build(); // 获取构建好的Notification | ||
notification.defaults = Notification.DEFAULT_SOUND; //设置为默认的声音 | ||
startForeground(110, notification); | ||
|
||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
stopForeground(true); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/hyphenate/chatuidemo/domain/VideoEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.hyphenate.chatuidemo.domain; | ||
|
||
import android.net.Uri; | ||
|
||
public class VideoEntity { | ||
public int ID; | ||
public String title; | ||
public String filePath; | ||
public int size; | ||
public int duration; | ||
public Uri uri; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.