标签: lockscreen

Android:在屏幕锁定时检测 Android 中的按键操作

key-presses屏幕锁定时是否可以在Android中检测到?我希望能够在屏幕关闭时检测到何时按下中央方向键按钮。

android lockscreen

5
推荐指数
0
解决办法
611
查看次数

锁屏上的活动 - 解除它会恢复之前的活动

假设我的应用程序运行正常,显示 Activity A。然后用户锁定手机。A 尽职尽责地睡觉 ( onPause())。在屏幕关闭的某个时候,我需要向用户展示一些东西。因此,从我的后台代码(服务)中,我为 B 调用 startActivity,并传递以下标志:

FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_NEW_TASK
Run Code Online (Sandbox Code Playgroud)

onCreate()B 中,我添加以下窗口标志

FLAG_SHOW_WHEN_LOCKED 
FLAG_TURN_SCREEN_ON 
FLAG_DISMISS_KEYGUARD 
Run Code Online (Sandbox Code Playgroud)

一切正常 - B 现在出现在键盘锁的顶部。

在稍后的某个时间点,我希望解雇 B,因此从 BI call 中dismiss(),它按预期工作。这就是出错的地方:我现在没有返回锁定屏幕,而是在锁定屏幕上运行 A。

当我解雇 B 时,如何阻止操作系统恢复 A?

谢谢。

android lockscreen keyguard android-activity

5
推荐指数
1
解决办法
1271
查看次数

通过主屏幕替换技术了解Android上的自定义锁定实现

我一直在研究这个问题.我本周提出了一个相关的问题.该地区最有用和最相关的链接是这个这个.我想了解它是如何工作的,如果实现为主屏幕替换应用程序.

快速提问:

  • 如果实现哪个屏幕应该设置为默认?我们的主屏幕更换或原始主屏幕?
  • 这个问题的答案之后,请阅读评论,其中asker想出了一个方法.最后他说:

    "想出来!必须使用setComponentEnabledSetting()禁用清单意图过滤器,然后在活动弹出时将其重新打开.感谢您的帮助!"

这到底是什么意思?我不太明白这里的逻辑.请帮忙?

  • 基本上,我和这位提问者有同样的疑问(请参阅下面的评论 @CoffeeCrisp 的答案).但是,我无法理解解决方案以及此处究竟发生了什么.请帮忙?

谢谢.

编辑:请不要贬低它.如果我的结果需要改进,请在评论中提出建议,以便我有时间进行更改.非常感谢.

java android homescreen lockscreen android-intent

5
推荐指数
1
解决办法
2967
查看次数

将图像和标题添加到锁定屏幕媒体控件

我即将向IOS 7的苹果商店提交一个"在播放列表中播放播客"的音频应用.

我正在使用PhoneGap 3.0,除了在锁定屏幕上添加音频标题和相应图像之外,我能够完成所有工作.

如何将歌曲和图像标题添加到锁定屏幕?

audio lockscreen ios cordova

5
推荐指数
1
解决办法
1074
查看次数

Android中的主页按钮覆盖

我试图了解在Android中覆盖主页按钮功能的方法.我正在做一个LockScreen应用程序和HOME按钮正在解锁设备.

我一直在研究过去3天的方法,我发现的所有解决方案都不是100%有效(主要是由于HOME的性质).

在这三天里,我已经为下面的所有解决方案实施了解决方案,但我仍然不满意.

问题:

我希望能够像AppStore中的WidgetLocker应用程序一样覆盖HOME按钮功能.WidgetLocker不是一个家庭发射器,它仍然可以比任何人更好地覆盖HOME.

链接到WidgetLocker应用程序

放弃

  • 首先,我知道这是Android中的安全措施,因此应用程序无法完全控制设备,我同意这一点.
  • 官方的方法是实现一个家庭发射器,它是我的首选,不幸的是我的老板仍然不是100%相信我选择的路径,直到我耗尽所有其他可能性.
  • 它必须是4.0+版本的android

解决方案

  • 实现作为Home启动器,捕获HOME意图并处理主页按钮按下,这有问题,用户必须选择应用程序作为默认的主启动器,可能不明白为什么(我知道的另一个问题,但仍然)
  • 实现具有SYSTEM_OVERLAY视图的服务,该视图在每次设备被锁定时启动,有效地在所有内容之上,不幸的是(或者幸运的是安全性)按下主页按钮仍然被发送到下面的应用程序并且默认的主启动器仍然是调用.
  • 实现一个与实现锁定屏幕的活动并行的活动,其中包含以我的应用程序选项以编程方式激活/停用的HOME Intent,有效地将主应用程序按需更改为homelauncher,当调用此活动时,它会启动锁定屏幕活动.

有没有其他方法可以做到这一点?

提前致谢.

java android lockscreen

5
推荐指数
1
解决办法
1866
查看次数

iOS - 允许我的应用在锁定屏幕上显示信息吗?

是否可以在我的应用程序中在锁定屏幕上显示信息?例如,倒数计时器?我知道 Apple 的内置应用程序,例如时钟,可以做到这一点。但它是否可以使用公共 API?

不,我不是在谈论推送或本地通知。我想为我的目的显示和实际倒数计时器,以便用户可以关闭应用程序并通过扫一眼锁定屏幕来获取计时器的更新。

timer lockscreen ios

5
推荐指数
1
解决办法
1904
查看次数

当应用程序未处于活动状态时,Android 通知声音不播放

所以,我通过网络搜索,并没有看到任何人遇到我遇到的这个问题。

我正在构建一个需要推送通知的应用程序。推送通知显示在状态栏和锁定屏幕上,但仅在应用程序处于活动状态时发出声音。我不知道我错过了什么。

这是我的代码:

public class PushListenerService extends GcmListenerService {

    @Override
    public void onMessageReceived(String from, Bundle data) {
        Log.d("FROM", from);
        Bundle pushNotification = (Bundle) data.get("notification");
        String title = pushNotification.get("title").toString();
        String body = pushNotification.get("body").toString();
        Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        NotificationManager notificationManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder notification = new Notification.Builder(this);

        notification.setContentTitle(title)
                    .setContentText(body)
                    .setSmallIcon(R.drawable.portrait_front)
                    .setSound(alarmSound);

        notificationManager.notify(0, notification.build());
    }
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!

编辑:添加清单以供进一步检查:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sth.idapp.android.privateapp">

<application android:allowBackup="true"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:largeHeap="true"
    android:theme="@style/AppTheme">

    <activity
        android:screenOrientation="portrait"
        android:name=".start.StartActivity"
        android:theme="@style/AppTheme.HideActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity> …
Run Code Online (Sandbox Code Playgroud)

android push-notification lockscreen

5
推荐指数
1
解决办法
2037
查看次数

锁屏iPhone的音乐控制

我正在开发音乐应用程序,但对于锁定屏幕控制,我无法分配持续时间和已用时间

这是我的代码

let commandCenter = MPRemoteCommandCenter.shared()

        commandCenter.previousTrackCommand.isEnabled = true;
        commandCenter.previousTrackCommand.addTarget(self, action:#selector(home_ViewController.btn_rewind(_:)))

        commandCenter.nextTrackCommand.isEnabled = true
        commandCenter.nextTrackCommand.addTarget(self, action:#selector(home_ViewController.btn_fast(_:)))

        commandCenter.playCommand.isEnabled = true
        commandCenter.playCommand.addTarget(self, action:#selector(home_ViewController.play_player))

        commandCenter.pauseCommand.isEnabled = true
        commandCenter.pauseCommand.addTarget(self, action:#selector(home_ViewController.pause_player))

        commandCenter.togglePlayPauseCommand.isEnabled = true
        commandCenter.togglePlayPauseCommand.addTarget(self, action:#selector(home_ViewController.togglePlay_Pause))

        commandCenter.skipBackwardCommand.isEnabled = false
        commandCenter.skipForwardCommand.isEnabled = false

        if #available(iOS 9.1, *) {
            commandCenter.changePlaybackPositionCommand.isEnabled = true
        } else {
            // Fallback on earlier versions
            return
        }
Run Code Online (Sandbox Code Playgroud)

和媒体信息

func setLockInfo()
    {
        let url = URL(string: song_UrlString)
        let data = try? Data(contentsOf: url!)
        let art = MPMediaItemArtwork.init(image: UIImage(data: data!)!)



        let songInfo :[String : …
Run Code Online (Sandbox Code Playgroud)

lockscreen mpnowplayinginfocenter swift3

5
推荐指数
1
解决办法
953
查看次数

单击自定义通知时提示解锁锁定屏幕

我在锁定屏幕中显示了一个自定义通知。单击通知后,我正在使用广播待处理意图向我的应用程序发送消息。稍后在广播接收器中启动一个活动。

问题是,一旦我点击通知,它就会从锁屏中消失,并且活动在锁屏后面启动。它不会要求用户解锁屏幕。

我的要求是要求用户在通知的点击事件发送广播后立即解锁屏幕。我怎么做?

我可以找到这个看起来像我的问题的问题。但不幸的是,没有答案。

这是一些解释我所做的通知创建的代码。

/**
 * Method to render Notification
 */
private void showNotification() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    /* set mandatory stuff on builder */

    Notification notification = builder.build();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notification.bigContentView = createCustomView(context);
    }

    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(getNotificationId(), notification);
}

/**
 * Method to return notification click's PendingIntent
 */
private PendingIntent getNotificationClickIntent() {
    Intent bcIntent = new Intent(OPEN_APP);
    bcIntent.putExtra(EXTRA_DEEP_LINK_URL, getDeepLinkUrl());

    return PendingIntent.getBroadcast(
        context, getReqCode(), bcIntent, PendingIntent.FLAG_ONE_SHOT);
}

/**
 * …
Run Code Online (Sandbox Code Playgroud)

notifications android lockscreen

5
推荐指数
1
解决办法
1347
查看次数

在Android O上显示锁定屏幕对话框

我能够在Oreo之前成功地在API上的锁定屏幕上添加一个对话框.似乎谷歌不再允许TYPE_SYSTEM_ERROR这个API上的标志了.

有没有办法在Android O上的锁定屏幕上显示对话框?


适用于<Android O的代码

int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_DIM_BEHIND;

        int type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;

        WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                0,
                0,
                type,
                flags,
                PixelFormat.RGBA_8888);
Run Code Online (Sandbox Code Playgroud)

android dialog lockscreen android-8.0-oreo android-8.1-oreo

5
推荐指数
0
解决办法
295
查看次数