我有一个Android应用程序.当应用程序运行时,应该静音或禁用警报.关闭应用程序后,应再次启用警报.我用过这段代码:
AudioManager AudiMngr = (AudioManager) getSystemService(AUDIO_SERVICE);
AudiMngr.setRingerMode(AudioManager.RINGER_MODE_SILENT);
AudiMngr.setStreamVolume(AudioManager.STREAM_ALARM, 0, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
Toast toast = Toast.makeText(getApplicationContext(), "Sound Muted", Toast.LENGTH_SHORT);
toast.show();
Run Code Online (Sandbox Code Playgroud)
但它仅在应用程序启动时有效.当警报满足警报时间时,它将启用.我希望在应用程序关闭之前将警报静音.我怎样才能做到这一点?
我可以知道为什么我的自定义listview适配器看起来像这样吗?
图片:
代码:
MainActivity.java
public class MainActivity extends AppCompatActivity {
CurrencyRatesDetails crd = new CurrencyRatesDetails();
TextView inputCurrTV, convertedAmtTV;
ListView currencyLV;
EditText inputAmtET;
ArrayAdapter<String> adapter;
String[] currNameArr = crd.getNames();
String[] currCodeArr = crd.getCodes();
String[] currRateArr = crd.getRates();
Context context;
int index = 0;
//String[] rateCurrArr = {"AUD", "BGN", "BRL", "CAD", "CHF", "CNY"};
//double[] rateArr = {0.944, 1.2824, 2.2842, 0.96158, 0.70946, 4.8624}
Menu myMenu = null;
double rate, amtInput, finalConversion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
inputAmtET …Run Code Online (Sandbox Code Playgroud) Android Studio 2.3、Android 4.3、Galaxy Nexus。
我希望所选按钮(单击时)隐藏软键盘。
问题:
我正在尝试使用Laravel或PHP获取从应用程序端存储到Firebase Analytics的事件记录。控制台中未显示任何数据,但大约每 30 秒发生一次事件。
是火力地堡Analytics(分析)的存储设施?是火力地堡分析和火力地堡数据库一样吗?
我试过使用该kreait/firebase-php库,但我无法获取存储在Firebase Analytics的事件数据。
php laravel firebase firebase-realtime-database firebase-analytics
我有一个 JavaFx 应用程序,我尝试在无头模式下运行 TestFX junit。(在正常模式下工作)。在 Gradle 中,我配置了 openjfx-monocle:
compile group: 'org.testfx', name: 'openjfx-monocle', version: '8u76-b04'
Run Code Online (Sandbox Code Playgroud)
作为我启动 junit 时的参数,我使用以下内容:
-Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k -Dtestfx.setup.timeout=2500 -Dheadless.geometry=1920x1080-64
Run Code Online (Sandbox Code Playgroud)
我的操作系统是 Windows 7 Proffesional 64 位,jdk 是“1.8.0_152”。
我试图改变参数 -Dheadless.geometry 但没有结果。任何的想法?
收到的错误是:
java.nio.BufferOverflowException
at java.nio.DirectIntBufferU.put(DirectIntBufferU.java:363)
at com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:153)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.lang.Thread.run(Thread.java:748)`
Run Code Online (Sandbox Code Playgroud) 我已经通读了有关 yarn 命令和 yarn.lock 的文档,我相信 yarn.lock 文件的全部意义在于使用该文件中指定的版本。
我很好奇的是:yarn.lock 中指定的版本什么时候实际使用?我在 package.jsonyarn install和 reran 中手动更改了一个包的版本,并且更新了 yarn.lock 文件以使用新版本。我认为它会被锁定,因此在 package.json 中指定什么新版本并不重要,只要 yarn.lock 为该包指定了一个版本,它就会使用旧版本。
如果这就是 yarn.lock 应该如何工作,那么为什么不在 package.json 中指定 EXACT 版本,而不是在版本号前面使用 ~ 或 ^ 。现在我必须这样做,以便在运行时不更改 yarn.lock 文件yarn install。
那么什么时候真正使用锁定版本/这是使用yarn.lock的正确方法吗?
下面的代码片段....
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
///////////Do something////////////////////////
showtext.startScan();
//SEt Alarm
Intent intent = new Intent(this, TextReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+9000, pi);}
Run Code Online (Sandbox Code Playgroud)
和我的接收者:
TextReceiver extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
///Show text/////
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我在9sn之后运行程序时,我收到一条错误"应用程序意外停止".为什么我会收到此错误?
我的目标是每隔9sn显示一次文本.AlarmManager主要活动的正确用法是什么?
或者我应该设置闹钟BroadcastReceiver?哪一个有意义:am.setRepeating或者am.set就我的目标而言?
**编辑:如何更改我的警报代码以在广播接收器中运行?**
我试图在char**变量中存储文件列表.
scandir()完成正常,但在尝试打印char**时出现分段错误.
这是代码:
int main()
{
char** fileList;
int noOfFiles;
char* path = ".";
makeList(&fileList, &noOfFiles, path);
return 0;
}
void makeList(char ***fileList, int* noOfFiles, char* path){
struct dirent **fileListTemp;
*noOfFiles = scandir(path, &fileListTemp, NULL, alphasort);
int i;
fileList = (char***)malloc(sizeof(char***));
*fileList = (char**)malloc(*noOfFiles * sizeof(char*));
printf("total: %d files\n",*noOfFiles);
for(i = 0; i < *noOfFiles; i++){
*fileList[i] = (char*)malloc(strlen(fileListTemp[i] -> d_name) *sizeof(char));
strcpy(*fileList[i], fileListTemp[i] -> d_name);
printf("%s\n",*fileList[i]);
}
return;
}
Run Code Online (Sandbox Code Playgroud)
打印2个文件名后,这会出现分段错误.
输出:
总计:27个档案.
..
.jv
分段故障(核心转储)
我想选择表格列的最大值.我正在使用PHP和MySQL.这是我到目前为止:
$max = "SELECT MAX(Id) FROM trialtabel2";
$max1 = mysqli_query($dblink, $max);
echo= $max1;
Run Code Online (Sandbox Code Playgroud)
我的调试器只是说它是一个返回a的查询0 boolean value (false).我无法在互联网上的任何地方找到具体的答案.
这是我的主要功能:
void main(int argc, char **argv)
{
if (argc >= 4)
{
ProcessScheduler *processScheduler;
std::cout <<
"Running algorithm: " << argv[2] <<
"\nWith a CSP of: " << argv[3] <<
"\nFilename: " << argv[1] <<
std::endl << std::endl;
if (argc == 4)
{
processScheduler = new ProcessScheduler(
argv[2],
atoi(argv[3])
);
}
else
{
processScheduler = new ProcessScheduler(
argv[2],
atoi(argv[3]),
atoi(argv[4]),
atoi(argv[5])
);
}
processScheduler -> LoadFile(argv[1]);
processScheduler -> RunProcesses();
GanntChart ganntChart(*processScheduler);
ganntChart.DisplayChart();
ganntChart.DisplayTable();
ganntChart.DisplaySummary();
system("pause");
delete processScheduler;
}
else
{ …Run Code Online (Sandbox Code Playgroud)