几个Android O通知问题:
1)我创建了一个Notification Channel(见下文),用.setChannelId()调用构建器(传入我创建的频道的名称,"wakey";然而,当我运行应用程序时,我收到一条消息我没有向渠道"null"发布通知.可能是什么导致了这个?
2)我怀疑#1的答案可以在它要检查的"日志"中找到,但我检查了logcat并且没有看到任何关于通知或频道的信息.它说要查看的日志在哪里?
这是我用来创建频道的代码:
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = context.getString(R.string.app_name);
String description = "yadda yadda"
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL, name, importance);
channel.setDescription(description);
notificationManager.createNotificationChannel(channel);
Run Code Online (Sandbox Code Playgroud)
这是生成通知的代码:
Notification.Builder notificationBuilder;
Intent notificationIntent = new Intent(context, BulbActivity.class);
notificationIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); // Fix for https://code.google.com/p/android/issues/detail?id=53313
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Intent serviceIntent = new Intent(context, RemoteViewToggleService.class);
serviceIntent.putExtra(WakeyService.KEY_REQUEST_SOURCE, WakeyService.REQUEST_SOURCE_NOTIFICATION);
PendingIntent actionPendingIntent = PendingIntent.getService(context, 0, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT);
_toggleAction = new Notification.Action(R.drawable.ic_power_settings_new_black_24dp, context.getString(R.string.toggle_wakey), actionPendingIntent);
notificationBuilder= new Notification.Builder(context)
.setContentTitle(context.getString(R.string.app_name))
.setContentIntent(contentIntent) …Run Code Online (Sandbox Code Playgroud) 我正在尝试检测蓝牙设备当前是否使用API 14或更高版本连接到Android设备.看起来我应该能够使用BluetoothSocket.isConnected()方法,但不管我做了什么,到目前为止,我只是因为任何事情得到了回报,无论是否连接.
AndroidManifest包含以下行:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Locale 4.x supports API 14 or greater. -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<uses-feature android:name="android.hardware.bluetooth" />
Run Code Online (Sandbox Code Playgroud)
并且有问题的代码:
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
for (BluetoothDevice device : pairedDevices) {
Log.i(Constants.LOG_TAG, String.format(Locale.US, "Device: %s connected: %b", device.getName(), isConnected(device))); //$NON-NLS-1$z
}
}
private boolean isConnected(BluetoothDevice device) {
BluetoothSocket socket = null;
// Get a BluetoothSocket for a connection with the given BluetoothDevice
UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
try { …Run Code Online (Sandbox Code Playgroud) 我已根据_references.js(http://blog.craigtp.co.uk/post/Javascript-jQuery-Intellisense-in-Visual-Studio-2012.aspx)中设置的引用设置我的IDE以显示JS Intellisense .在这样做时,您必须将JavaScript IntelliSense Reference Group设置为"Implicit(Web)",我已经完成了.一段时间以来,它的工作非常精彩.
然而,在一些看似随机的时间(可能是几小时或几天,但通常不超过一天左右)后,我的JS IntelliSense停止工作.当我返回参考组设置时,我发现参考组已恢复为"隐式(Windows)".
有没有其他人有这个问题?可能是什么造成的,或者这是VS2012中的一个错误(这是发布的版本)?
谢谢!
我正在尝试使用GcmNetworkManager在我的应用程序中安排定期任务,该任务运行到API级别17.我按照GCM网络管理器页面(https://developers.google.com/上的说明)设置了所有内容.云消息/网络管理员):
在我的AndroidManifest.xml中,我有:
<service
android:name=".services.MyService"
android:exported="true"
android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
<intent-filter>
<action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
在我的申请中,我有:
long periodSecs = 30L; // the task should be executed every 30 seconds
long flexSecs = 15L; // the task can run as early as -15 seconds from the scheduled time
String tag = "myScan|1";
PeriodicTask periodic = new PeriodicTask.Builder()
.setService(MyService.class)
.setPeriod(periodSecs)
.setFlex(flexSecs)
.setTag(tag)
.setPersisted(false)
.setRequiredNetwork(com.google.android.gms.gcm.Task.NETWORK_STATE_ANY)
.setRequiresCharging(false)
.setUpdateCurrent(true)
.build();
GcmNetworkManager.getInstance(this).schedule(periodic);
Run Code Online (Sandbox Code Playgroud)
我有MyService,看起来像:
public class MyService extends GcmTaskService {
@Override
public int onRunTask(TaskParams taskParams) {
Log.info("onRunTask: …Run Code Online (Sandbox Code Playgroud) 我已经实现了 Play Billing Library,它总体上非常成功 - 但似乎有几次购买(或获取可用产品)调用失败,响应代码为 6(API 操作期间出现致命错误)。
没有提供其他信息,并且大多数调用都成功了,所以这不是我完全做错了什么的问题。如何解决此问题?有没有办法知道是什么导致了这个错误?
我被告知,"一旦用户进入观众,他们将永远留在那些观众中".我很好奇在用户的背景下"永远"有多久了?例如,如果用户更换手机,或卸载应用程序,然后再重新安装,用户是否会在这些转换中持续存在,或者每个用户都是单独的用户?如果我在一个Firebase项目中有多个应用,那么用户是否会在该项目中的所有应用中出现在相同的受众群体中?
Firebase Analytics认为什么是独特/新用户?
我希望尝试使用Audience的一个用例是,我想要一个"现有用户"(由"first_open_time <= {some date}"定义)和"新用户"的受众群体.我想为新用户实现一些更改,但我希望让现有用户暂时拥有"遗留"行为,转换速度会更慢.如果一个人在"现有用户"中,那么获得一部新手机,或者卸载并稍后重新安装该应用,他们会突然成为新用户,因此不再是"现有用户"受众群体吗?
另一个用例:我有一个现有的应用程序,我正在编写一个全新的应用程序,它将有一个新的软件包名称,因此将成为我所有现有用户的新安装.我想将它们全部转移到新的应用程序免费,我能想到的最好的方法是将新旧应用程序放在同一个Firebase项目中,并将旧应用程序的用户放在受众中,并且当他们运行新版本时,如果他们在"旧应用用户"中,它会自动为他们提供高级功能.
为了对用例充满信心,我需要更好地理解Firebase的"用户"定义 - 它是否会在卸载过程中持续存在,在设备之间进行转换,您是否可以在项目中的应用之间共享受众?
谢谢!
我试图使火力地堡分析观众,用"应用程序版本"设置为"包含'调试’".我的应用程序的调试版本在Version Name字符串的末尾添加了"-debug".
当我运行应用程序,但是,当我的会话记录火力地堡数据,它不记录任何对于"调试的观众."
我最终希望得到一个世界,我可以使用远程配置,创建我可以在测试中使用的配置项,但我不必担心当我推送应用程序时,在某些测试模式下意外地将配置保持活动状态.现在,我的解决方案是使用"if(!BuildConfig.DEBUG)"包装所有调用以应用远程配置,但我肯定会忘记一次,并为所有用户将"isPremiumUser"设置为true推送应用程序,或者像这样愚蠢的东西:).
有没有办法创建开发人员构建的受众,无论是通过版本名称还是任何其他方法?
谢谢!