Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
turingos
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 54299ce3
authored
Aug 22, 2019
by
cuiliang.shi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打开联系人 音乐/FM 后台播放控制
1 parent
7f713e7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
4 deletions
app/src/main/java/com/toscl/turingos/MainActivity.java
app/src/main/java/com/toscl/turingos/util/SkillsSlotUtil.java
app/src/main/java/com/toscl/turingos/MainActivity.java
View file @
54299ce
...
...
@@ -2,10 +2,12 @@ package com.toscl.turingos;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.Color
;
import
android.graphics.drawable.AnimationDrawable
;
import
android.media.AudioManager
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Message
;
...
...
@@ -295,10 +297,48 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected
void
onResume
()
{
super
.
onResume
();
muteAudioFocus
(
this
,
true
);
/* if (!mFirstIn) {
initSDK();
}*/
}
public
static
boolean
muteAudioFocus
(
Context
context
,
boolean
bMute
)
{
if
(
context
==
null
){
Log
.
d
(
"ANDROID_LAB"
,
"context is null."
);
return
false
;
}
boolean
bool
=
false
;
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
if
(
bMute
){
int
result
=
am
.
requestAudioFocus
(
null
,
AudioManager
.
STREAM_MUSIC
,
AudioManager
.
AUDIOFOCUS_GAIN_TRANSIENT
);
bool
=
result
==
AudioManager
.
AUDIOFOCUS_REQUEST_GRANTED
;
}
else
{
int
result
=
am
.
abandonAudioFocus
(
null
);
bool
=
result
==
AudioManager
.
AUDIOFOCUS_REQUEST_GRANTED
;
}
Log
.
d
(
"ANDROID_LAB"
,
"pauseMusic bMute="
+
bMute
+
" result="
+
bool
);
return
bool
;
}
private
void
pauseMusic
()
{
AudioManager
audioManager
=
(
AudioManager
)
getSystemService
(
Context
.
AUDIO_SERVICE
);
Intent
freshIntent
=
new
Intent
();
if
(
audioManager
.
isMusicActive
()){
freshIntent
.
setAction
(
"com.android.music.musicservicecommand.pause"
);
// freshIntent.putExtra("command", "pause");
sendBroadcast
(
freshIntent
);
}
freshIntent
.
setAction
(
"com.thunderst.radio.RadioService.SHUTDOWN"
);
sendBroadcast
(
freshIntent
);
}
@Override
protected
void
onStop
()
{
super
.
onStop
();
muteAudioFocus
(
this
,
false
);
}
private
ScrollEditText
mResultText
;
private
ArrayList
<
ContentBean
>
userlist
,
robotlist
;
...
...
@@ -559,7 +599,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
if
(!
packageName
.
equals
(
""
))
{
ApiResultCode
.
doStartApplicationWithPackageName
(
packageName
,
context
);
try
{
ApiResultCode
.
doStartApplicationWithPackageName
(
packageName
,
context
);
}
catch
(
Exception
e
){
handleMyTips
(
"没有找到该应用"
);
}
}
else
{
handleMyTips
(
"没有找到该应用"
);
}
...
...
@@ -863,13 +907,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
mGlobalDialog
=
new
SweetAlertDialog
(
mContext
,
SweetAlertDialog
.
SUCCESS_TYPE
)
.
setTitleText
(
list
.
get
(
0
))
.
setContentText
(
""
);
mGlobalDialog
.
show
();
mGlobalDialog
.
findViewById
(
R
.
id
.
confirm_button
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
mGlobalDialog
.
setConfirmClickListener
(
new
SweetAlertDialog
.
OnSweetClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
SweetAlertDialog
sweetAlertDialog
)
{
operateAll
();
}
});
mGlobalDialog
.
show
();
}
else
{
handleMyTips
(
getString
(
R
.
string
.
app_name
)
+
"没听清,请再说一遍吧"
);
...
...
app/src/main/java/com/toscl/turingos/util/SkillsSlotUtil.java
View file @
54299ce
...
...
@@ -121,6 +121,8 @@ public class SkillsSlotUtil {
}
appMap
.
put
(
"联系人"
,
"com.sprd.simple.launcher/dx.com.contactforlaunch.ui.ContactListActivity"
);
appMap
.
put
(
"通讯录"
,
"com.sprd.simple.launcher/dx.com.contactforlaunch.ui.ContactListActivity"
);
appMap
.
put
(
"收音机"
,
"com.android.fmradio/com.android.fmradio.FmMainActivity"
);
appMap
.
put
(
"音乐播放器"
,
"com.android.music/com.android.music.MusicBrowserActivity"
);
appMap
.
put
(
"紧急呼叫"
,
"com.android.sos/com.android.sos.SosActivity"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment