我有一个应用程序,持续通知,以帮助记忆.我希望能够通过其中一个操作按钮关闭此通知,但我不想在按下按钮时打开应用程序.我更喜欢使用内置的通知操作按钮,而不是创建一个RemoteViews对象来填充通知.我在我的应用程序中看到了一个在这个按钮上使用BroadcastReceiver的帖子提及,虽然他的教程非常无益,但听起来这是朝着正确的方向发展.
Intent resultIntent = new Intent(getBaseContext(), Dashboard.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(getBaseContext());
stackBuilder.addParentStack(Dashboard.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
Intent cancel = new Intent(getBaseContext(), CancelNotification.class);
stackBuilder.addParentStack(Dashboard.class);
stackBuilder.addNextIntent(cancel);
PendingIntent pendingCancel =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.Builder mb = new NotificationCompat.Builder(getBaseContext());
mb.setSmallIcon(R.drawable.cross_icon);
mb.setContentTitle(ref);
mb.setContentText(ver);
mb.setPriority(NotificationCompat.PRIORITY_LOW);
mb.setOngoing(true);
mb.setStyle(new NotificationCompat.BigTextStyle().bigText(ver));
mb.setContentIntent(resultPendingIntent);
mb.addAction(R.drawable.ic_cancel_dark, "Dismiss", pendingCancel);
manager.notify(1, mb.build());
Run Code Online (Sandbox Code Playgroud) 我最近将Android Studio从0.6更新到0.8.6,似乎已经删除了指定默认"运行"配置的能力(或者移动到我需要帮助查找的位置).我可以在调试或发布模式下生成签名的APK(生成向导已更改为允许我在此时选择构建变体)但似乎无法找到如何选择一般的构建变体使用.换句话说,当我单击"运行"时,gradle会assembleRelease在我需要运行时执行assembleDebug.知道怎么改变这个吗?
编辑:当我选择"调试"而不是"运行"gradle仍然选择运行assembleRelease,所以我得到这个错误
Cannot debug application com.caseybrooks.scripturememory on device lge-vs985_4g-VS9854Gc824b3f1.
This application does not have the debuggable attribute enabled in its manifest.
If you have manually set it in the manifest, then remove it and let the IDE automatically assign it.
If you are using Gradle, make sure that your current variant is debuggable.
Run Code Online (Sandbox Code Playgroud)
但是,如果我将debuggable="true"属性添加到清单中,则构建将失败.我的build.gradle是否正确?
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
} …Run Code Online (Sandbox Code Playgroud) 我有一个模板化的类,我试图使用operator <<打印出来但是得到错误:
Vertex.h:24:16: error: use of deleted function 'std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)'
Run Code Online (Sandbox Code Playgroud)
其中第24行引用以下代码中的输出运算符的返回:
/In declaration of templated class Vertex
friend std::ostream operator<<(std::ostream& ost, const Vertex<T>& v) {
ost << v.getItem();
return ost;
}
//In main function
Vertex<int>* v1 = new Vertex<int>();
v1->setItem(15);
cout << *v1 << endl;
Run Code Online (Sandbox Code Playgroud)
如何才能使此输出有效?
在我的Android应用程序中,我使用的是一个标准的SQLite数据库,其中一个辅助类有一个包含3列的表.在最近的更新中,我不得不在表中添加另一列,但是有些用户报告了崩溃,其中(通过堆栈跟踪判断)我认为来自新版本试图从不存在的列读取因为数据来自旧版本.除了手动备份和还原之外,如何在更新之间保护用户数据?
以下是完整更新的数据库类的链接:https: //github.com/cjbrooks12/scripturememory/blob/working/src/com/caseybrooks/scripturememory/databases/VersesDatabase.java