我正在尝试创建一个在设备的蓝牙打开时显示祝酒的应用程序.即使我的应用程序没有运行,我也想这样做.所以我应该使用广播接收器,添加一些权限,一个intent-filter到android清单并制作一个java类,但我不知道细节.
我该怎么办?我应该使用哪些权限?
我想检查我的 imageview 的背景,如果它等于我的 drawable 文件夹中的一些 drawable 就做某事。我怎样才能做到这一点?我试过这段代码,但没有答案:
layoutRoot.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (view.getBackground() == R.drawable.grid_single_bg_selected) {
//Do sth
}
}
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个可以控制我的IP摄像头的应用程序.VLC媒体播放器可以做到这一点,但我不知道如何将它嵌入我的应用程序中添加功能,如捕捉图片.我该怎么办?
我想创建一个自定义通知来直接从这样的通知回复短信:
据我所知,正常通知必须具有 64dp 高度,但您可以使用 API >16 中更大的通知作为可扩展通知,但我认为 64dp 高度适合我的情况。我使用了这段代码,但是当我的自定义通知布局有编辑文本时它崩溃了:
RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.widget);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContent(remoteViews);
Intent resultIntent = new Intent(context, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(100, mBuilder.build());
Run Code Online (Sandbox Code Playgroud)
错误:
android.app.RemoteServiceException: Bad notification posted from package com.example.x: Couldn't expand RemoteViews for: StatusBarNotification
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我正在尝试使用以下代码在命令提示符上运行代码:
ProcessStartInfo startInfo = new ProcessStartInfo("Cmd");
startInfo.Arguments = "/c tracert 8.8.8.8";
Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)
但它在运行代码后关闭,但我希望cmd保持打开状态.我该怎么办?