我试图让Android的TTS在服务中运行,但我不知道它为什么不工作,它编译,不会崩溃,但它只是不起作用.
吐司通知确实有效.
package alarm.test;
import android.app.Service;
import com.google.tts.TextToSpeechBeta;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyAlarmService extends Service {
private TextToSpeechBeta myTts;
private TextToSpeechBeta.OnInitListener ttsInitListener = new TextToSpeechBeta.OnInitListener() {
public void onInit( int arg0, int arg1 ) {
myTts.speak("", 0, null);
}
};
@Override
public void onCreate() {
// TODO Auto-generated method stub
myTts = new TextToSpeechBeta( this,
ttsInitListener );
Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG).show();
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
myTts.speak("something is working", TextToSpeechBeta.QUEUE_FLUSH, …Run Code Online (Sandbox Code Playgroud) 我有服务器组件通过HTTP连接到远程服务器并获得一些响应.如果我使用Phonegap for Android,我可以连接到java插件中的这样的服务器端代码吗?
我想做一个选择,用户的生日(日期字段)少于30天.
最好的方法是什么?我试过约会,但我不知道怎么把年份放在一边.
谢谢
我试图递归地填充一棵树,但我的代码只填写一个深度长度,然后退出。即每个节点只有一个孩子。有什么事情没有考虑到吗?
public static void populate(Node n, int depth, String player){
System.out.println("Depth: " + depth);
if(player.equalsIgnoreCase("X"))
player = "O";
else
player = "X";
int j = 0;
System.out.println("empty spots: " + ((Board)n.getData()).noOfEmpty());
for(int i=0; i<((Board)n.getData()).noOfEmpty(); i++){
if(((Board)n.getData()).getSquare(j).equalsIgnoreCase("X")
|| ((Board)n.getData()).getSquare(j).equalsIgnoreCase("O"))
j++;
else{
Board tmp = new Board(((Board)n.getData()), j, player);
Node newNode = new Node(tmp);
tree.insert(n, newNode);
populate(newNode, depth-1, player);
}
}
}
Run Code Online (Sandbox Code Playgroud)
PS,我检查noOfEmpty()返回值,它应该确定节点应该拥有的子节点数。
按要求编辑:@eznme 完整代码:
public class MinMax {
protected static Tree tree;
public static void createTree(Board b){
tree = …Run Code Online (Sandbox Code Playgroud) var fileList = Directory.GetFiles("./", "split*.dat");
int fileCount = fileList.Length;
int i = 0;
foreach (string path in fileList)
{
string[] contents = File.ReadAllLines(path); // OutOfMemoryException
Array.Sort(contents);
string newpath = path.Replace("split", "sorted");
File.WriteAllLines(newpath, contents);
File.Delete(path);
contents = null;
GC.Collect();
SortChunksProgressChanged(this, (double)i / fileCount);
i++;
}
Run Code Online (Sandbox Code Playgroud)
对于包含~20-30个大行(每行~20mb)的文件,当我执行ReadAllLines方法时,我有OutOfMemoryException.为什么这个异常会引发?我该如何解决?PS我在MacOS上使用Mono
我知道当你使用时par( fig=c( ... ), new=T ),你可以创建插图.但是,我想知道是否可以使用ggplot2库来创建"插图"图形.
更新1:我尝试使用par()with ggplot2,但它不起作用.
更新2:我发现了一个工作液在GGPLOT2 Google网上论坛使用grid::viewport().
我有一个ASP.Net MVC应用程序,它在我的本地开发机器上运行良好.但是当部署到IIS7时,在尝试登录时出现以下错误:
初始化字符串的格式不符合从索引0开始的规范
发布此错误的大多数人通过以某种方式更改其连接字符串来解决此问题.但是,本地和已部署应用程序上的连接字符串是相同的.连接字符串是这样的:
<add name="ApplicationServices" connectionString="Data Source=*server*\*instance*;Initial Catalog=*database*;Integrated Security=True;"
providerName="System.Data.SqlClient" />
Run Code Online (Sandbox Code Playgroud)
在我的情况下导致此错误的原因是什么?
我有一个特点,命名为Init:
package test
trait Init {
def init(): Any
}
Run Code Online (Sandbox Code Playgroud)
有一些类和一个对象,扩展了这个特性:
package test
object Config extends Init {
def init() = { loadFromFile(...) }
}
class InitDb extends Init {
def init() = { initdb() }
}
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,我将找到所有扩展的类和对象Init,并调用它们的init方法.
package test
object App {
def main(args: Array[String]) {
val classNames: List[String] = findAllNamesOfSubclassOf[Init]
println(classNames) // -> List(test.Config$, test.InitDb)
classNames foreach { name =>
Class.forName(name).newInstance().asInstanceOf[Init].init() // ***
}
}
}
Run Code Online (Sandbox Code Playgroud)
请注意" * "行.因为test.InitDb,没关系.但是,对于test.Config$ …
我在第三次演习中参加了僵尸实验室的第四次Rails.这是我的任务:创建将创建新Zombie的动作,然后重定向到创建的僵尸的节目页面.我有以下params数组:
params = { :zombie => { :name => "Greg", :graveyard => "TBA" } }
Run Code Online (Sandbox Code Playgroud)
我写了以下代码作为解决方案:
def create
@zombie = Zombie.create
@zombie.name = params[ :zombie [ :name ] ]
@zombie.graveyard = params[ :zombie [ :graveyard ] ]
@zombie.save
redirect_to(create_zombie_path)
end
Run Code Online (Sandbox Code Playgroud)
但是当我提交它时,我收到以下错误:
#<TypeError: can't convert Symbol into Integer>
我知道我犯了一个错误,但我无法弄清楚在哪里.请帮我.
我想在几个月内找出差异
目前我有这个代码:
dateInterval = [endDate timeIntervalSinceDate:startDate];
Run Code Online (Sandbox Code Playgroud)
但是这会以秒为单位返回一个值,我希望看到几个月内的日期之间的差异.
我该怎么做?
谢谢