标签: lockscreen

iOS KeyChain不从后台检索值

我目前正在iOS KeyChain中存储用户名(电子邮件)和电子邮件和密码的盐渍哈希.我正在使用这里发现的ARC'ified版本.

KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"MyCustomIdentifier" accessGroup:nil];
[wrapper setObject:APP_NAME forKey:(__bridge id)kSecAttrService];
[wrapper setObject:email forKey:(__bridge id)kSecAttrAccount];
[wrapper setObject:token forKey:(__bridge id)kSecValueData];
Run Code Online (Sandbox Code Playgroud)

当我需要在应用程序处于活动状态时拉出令牌以进行网络呼叫时,这一切都正常.它适用于从干净的启动登录,以及整个网络调用.当应用程序在后台时,问题就开始了.

请记住,这只是零星发生,我还没有把它固定到特定的iOS版本或设备上.

用户绊倒一个位置(区域监控),我想用他们的状态更新服务器.我尝试将令牌从钥匙串中取出,就像我为每个其他网络呼叫所做的那样,并更新状态.但对于一些用户来说,价值是零.没有它,我无法更新网络内容.为什么这对大多数人有效,但对于一小部分人来说不是这样?

KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"MyCustomIdentifier" accessGroup:nil];
NSString *token = [wrapper objectForKey:(__bridge id)kSecValueData];
Run Code Online (Sandbox Code Playgroud)

我已经回到了keychainwrapper的非ARC版本,但我仍然得到了相同的结果.我将不胜感激任何反馈.它只是我用户的一小部分,但这是一个我想解决的问题而不用担心.提前致谢.

此外,我的所有后台工作都在backgroundTask中设置,以防止事情超时.我对钥匙链的工作没有任何问题,但在令牌填满之前我不会让事情继续下去.

编辑 我发现我的问题是他们的钥匙串没有从后台检索值.我将在下面发布答案并接受它,因为我觉得这个问题可能会在以后对其他人有价值.

iphone background keychain lockscreen ios

81
推荐指数
2
解决办法
2万
查看次数

Android锁屏小工具

一些用户一直在问我的应用程序的Android锁屏小部件 - 我相信他们希望一个小部件保持在他们的锁定屏幕上,并允许他们与应用程序进行交互.

我找不到任何关于此的官方文档 - 我发现的唯一一个应用程序将带回主屏幕小部件并将它们放在锁定屏幕上.

有关构建真正的锁屏小部件的更多信息的任何线索?

android android-widget lockscreen

74
推荐指数
3
解决办法
7万
查看次数

Android活动超过默认锁定屏幕

如何在锁定屏幕上显示ActivityDialog显示?

通过在Activity.onCreate()方法中设置各种窗口类型,我已经尝试在屏幕打开时显示我的锁定活动:

TYPE_PRIORITY_PHONE
TYPE_SYSTEM_ALERT
TYPE_KEYGUARD

和其他人一起SYSTEM_ALERT_WINDOWINTERNAL_SYSTEM_WINDOW权限.

解锁设备后,我的活动可见.

更新:

我实际上已经设法显示我自己的Activity而不是默认锁定屏幕.除非您使用HOME按钮,否则它可以完美运行

android dialog lockscreen android-windowmanager android-activity

72
推荐指数
3
解决办法
8万
查看次数

Media Session Compat未在Pre-Lollipop上显示锁屏控件

我正在使用MediaSessionCompatAppCompat支持库修订版22.在Lollipop上我收到通知,而且锁屏背景也是专辑封面.一切都很酷.

在Pre-Lollipop设备上,锁屏上的音乐控件根本没有显示.这很奇怪,我尝试了一切,但它没有出现,甚至没有出现背景变化.

我希望有人能解决这个问题.

注意:RemoteControlClient曾经用于Lollipop和KitKat

/**
 * Initializes the remote control client
 */
private void setupMediaSession() {
    /* Activate Audio Manager */
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN);

    ComponentName mRemoteControlResponder = new ComponentName(getPackageName(),
            MediaButtonReceiver.class.getName());
    final Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(mRemoteControlResponder);
    mMediaSessionCompat = new MediaSessionCompat(getApplication(), "JairSession", mRemoteControlResponder, null);
    mMediaSessionCompat.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
    PlaybackStateCompat playbackStateCompat = new PlaybackStateCompat.Builder()
            .setActions(
                    PlaybackStateCompat.ACTION_SEEK_TO |
                    PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                    PlaybackStateCompat.ACTION_SKIP_TO_NEXT |
                    PlaybackStateCompat.ACTION_PLAY |
                    PlaybackStateCompat.ACTION_PAUSE |
                    PlaybackStateCompat.ACTION_STOP
            )
            .setState(
                    isPlaying() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED,
                    getCurrentPosition(), …
Run Code Online (Sandbox Code Playgroud)

android lockscreen android-mediaplayer android-5.0-lollipop

34
推荐指数
3
解决办法
9457
查看次数

开发android锁屏应用程序

我想开发自己的Android锁屏,它将取代默认的android锁屏.我不知道如何开始.

有关于它的任何教程或我可以在我的日食中下载和打开并运行的示例吗?

非常感谢

android lockscreen

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

Android如何在屏幕上显示通知

我一直致力于推送通知,我能够实现它并在状态栏上显示它,我面临的问题是我想显示它,即使手机是锁定的,在它所说的锁定屏幕下("拖动解锁"),我已经看过这样的通知,但无法找到任何示例.

示例: 就像您收到未接来电一样,它会在屏幕上的锁定按钮下显示.

码:

String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.icon_launcher;
CharSequence tickerText = "MyApplication";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.defaults |= Notification.DEFAULT_SOUND|Notification.DEFAULT_VIBRATE|Notification.DEFAULT_LIGHTS;;
CharSequence contentTitle = this.title;
CharSequence contentText = this.message;
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(NOTICE_ID, notification);
Run Code Online (Sandbox Code Playgroud)

notifications android lockscreen

28
推荐指数
3
解决办法
8万
查看次数

为Android 4.0或更高版本创建自定义锁屏?

我想为Android 4.0及更高版本创建自定义lockScreen,我已经尝试了创建锁屏的小部件,但它只支持android 4.2.

有没有其他方法来创建自定义android锁屏?

android android-widget lockscreen android-4.2-jelly-bean

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

创建Android锁屏应用程序.

如何创建一个锁屏应用程序,充当Android移动锁.我找到了一个,但它的代码构造很差,如果我按下物理主页键,它就会解锁,使应用程序变得毫无意义.

我确实遇到过一个论坛,说明在Android 4.x中删除了一些阻止主页按钮功能的方法

然而,我对锁屏有一个很棒的想法,但没有理由开始.如果有人对这个问题有任何了解,我很乐意听到.

谢谢大家:-)

java android lockscreen

25
推荐指数
1
解决办法
7万
查看次数

如何在锁定屏幕上执行通知操作(单击)?

TL; DR

如何在没有解锁的情况下从锁定屏幕发出一些有效的通知?单击操作,通知上的按钮或完成通知后,我想进行API调用(无需键入解锁代码)

细节

目标

基于这个问题的答案,我试图通过一个在锁定屏幕上工作的动作发出通知,而无需解锁设备.该操作不需要任何进一步的界面或交互(想想"发送API请求").

状态

通知和单击可以使用未锁定的设备.然而,当锁定时我仍然需要先输入解锁代码,所以要么有新的事情发生,要么我误解了它应该工作的方式.

如果我理解正确,我可以将我的可见性设置为'public'来显示内容(这是有效的),而不是定义一个动作(似乎不公开)我可以处理(现在可见)布局的点击.我尝试使用下面的代码,但显然它不起作用.

我已经尝试将意图发送到我的应用程序和服务,正如弗洛里安建议的那样.

这是我开始通知的代码(它存在于一个Activity中,代码缩短了以方便您使用)

private void startNotification() {

    NotificationCompat.Builder builder = 
            new NotificationCompat.Builder(this)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setOngoing(true)
            .setSmallIcon(R.drawable.abc_ic_menu_share_mtrl_alpha)
            .setContentTitle("title text")
            .setContentText("content text");

    Intent openIntent = new Intent(MyMainActivity.this, MyMainActivity.class);
    openIntent.setAction("some_string");
    PendingIntent pOpenIntent = PendingIntent.getActivity(this, 0, openIntent, 0);
    builder.setContentIntent(pOpenIntent);

    RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
    builder.setContent(view);

    NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotificationManager.notify(id, builder.build());

}
Run Code Online (Sandbox Code Playgroud)

如上所述,我也尝试过florian建议的服务,并将其作为电话:

    Intent yepIntent = new Intent(this, MyIntentService.class);
    yepIntent.setAction("test");
    yepIntent.putExtra("foo", true);
    yepIntent.putExtra("bar", "more info");
    PendingIntent yepPendingIntent = PendingIntent.getService(this, notificationId, yepIntent, PendingIntent.FLAG_CANCEL_CURRENT); …
Run Code Online (Sandbox Code Playgroud)

notifications android lockscreen android-service android-5.0-lollipop

24
推荐指数
2
解决办法
1万
查看次数

在android中获取解锁事件的方法?

有没有办法收到类似的东西PHONE_UNLOCKED(有BroadcastReceiver某种)?

我有一个运行的服务,显示Toast屏幕打开的时间.不幸的是,一些手机在解锁之前不会显示它.大多数时候,Toast消息已经消失了.

android broadcastreceiver lockscreen

22
推荐指数
1
解决办法
2万
查看次数