我正在尝试创建一个包含12个不同表的数据库,这些表一直运行到今天.现在,每次我卸载它并重新安装它(或只是清除应用程序数据)后第一次启动我的应用程序时,我会收到标题中显示的错误消息.但是,我第二次在收到此错误后启动应用程序它工作正常.下面的代码来自我的DatabaseHelper类,它与android记事本教程或多或少相同.
在我的活动中打开数据库之后出现此错误,我尝试进行第一次查询.
有什么可能导致这种情况以及如何解决它的任何建议?
private static class DatabaseHelper extends SQLiteOpenHelper {
private static String DB_PATH = "/data/data/my_app/databases/";
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
if (!checkDataBase()) {
db.execSQL(TABLE_1);
db.execSQL(TABLE_2);
db.execSQL(TABLE_3);
db.execSQL(TABLE_4);
db.execSQL(TABLE_5);
db.execSQL(TABLE_6);
db.execSQL(TABLE_7);
db.execSQL(TABLE_8);
db.execSQL(TABLE_9);
db.execSQL(TABLE_10);
db.execSQL(TABLE_11);
db.execSQL(TABLE_12);
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
db.execSQL("DROP …Run Code Online (Sandbox Code Playgroud) 所有突然的地图都停止在我的应用程序中工作,只是在左下角显示一个带有谷歌徽标的空白屏幕.
我得到的错误是:
I/Google Maps Android API? Google Play services package version: 4452038
I/ActivityManager? Start proc com.google.android.gms.maps for service com.google.android.gms/.maps.auth.ApiTokenService:
I/Google Maps Android API? Google Play services client version: 4452000
I/Google Maps Android API? Failed to contact Google servers. Another attempt will be made when connectivity is established.
E/Google Maps Android API? Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Run Code Online (Sandbox Code Playgroud)
我认为唯一可能的想法是身份验证错误.因为我尝试过不同的网络并且没有遇到麻烦.
问题可能出在build.gradle文件中吗?我想,因为问题在我搞砸了之后就开始了.
这是我的构建gradle:
apply plugin: 'android'
android { …Run Code Online (Sandbox Code Playgroud) android google-maps google-maps-android-api-2 android-studio
我正在尝试在我的场景中获得良好的鼠标移动,以便我可以围绕对象旋转.
我有两个问题,我可以弄清楚如何限制运动,使它永远不会在Y轴上旋转0度以下.(我不想从下面看到对象,只在上面)
我无法弄清楚的第二件事是如何使运动平稳.现在我在jsfiddle中取得的成就是在开始旋转之前摄像机移回其起始位置.
我的尝试:http://jsfiddle.net/phacer/FHD8W/4/
这是我没有得到的部分:
var spdy = (HEIGHT_S / 2 - mouseY) / 100;
var spdx = (WIDTH / 2 - mouseX) / 100;
root.rotation.x += -(spdy/10);
root.rotation.y += -(spdx/10);
Run Code Online (Sandbox Code Playgroud)
我想要的是不使用额外的库:http://www.mrdoob.com/projects/voxels/#A/afeYl
我正在尝试在gradle,android studio中设置一个漂亮的小版本脚本,每次我进行构建时版本名称都会增加,而版本代码只会在我发布版本时增加.这可能吗?
我认为可以解决的是检查下面的if语句是否是一个版本.但是我如何检查它是否是一个版本?
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
def versionPropsFile = file('version.properties')
def code
def name
def Properties versionProps
if (versionPropsFile.canRead()) {
versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
code = versionProps['VERSION_CODE'].toInteger() + 1
name = versionProps['VERSION_NAME'].toInteger() + 1
versionProps['VERSION_CODE']=code.toString()
versionProps['VERSION_NAME']=name.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
versionCode code
versionName "1.2." + name
minSdkVersion 14
targetSdkVersion 19
}
} else {
throw new GradleException("Could not read version.properties!")
}
signingConfigs {
debug {
...
}
releaseKey {
...
}
}
buildTypes {
debug …Run Code Online (Sandbox Code Playgroud) 我正试图在领域进行查询.但是我一直在equalTo中获得一个空指针异常("id",38)
这是例外:
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference
at io.realm.RealmQuery.getColumnIndices(RealmQuery.java:140)
at io.realm.RealmQuery.equalTo(RealmQuery.java:199)
at es.treenovum.paedocuments.services.OfflineService$WidgetOpsNewest.loadTags(OfflineService.java:340)
at es.treenovum.paedocuments.services.OfflineService$WidgetOpsNewest.doInBackground(OfflineService.java:228)
at es.treenovum.paedocuments.services.OfflineService$WidgetOpsNewest.doInBackground(OfflineService.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 3 more
Run Code Online (Sandbox Code Playgroud)
异常发生在equalTo行:
Category categoryResult = realm.where(Category.class)
.equalTo("id", category.getId())
.findFirst();
Run Code Online (Sandbox Code Playgroud)
int category.getId()不为null或为空.境界也不是.
如果是我第一次运行应用程序,则db为空.这会导致这个吗?不应该在结果中返回null或0而不是抛出异常吗?
编辑:添加了类别类.eclipse生成的所有getter和setter.
import io.realm.RealmObject;
import io.realm.annotations.RealmClass;
import com.google.gson.annotations.SerializedName;
@RealmClass
public class Category extends RealmObject {
@SerializedName("id")
private int id;
@SerializedName("text")
private String text;
public int getId() {
return id;
}
public void setId(int id) {
this.id …Run Code Online (Sandbox Code Playgroud) 和许多其他Android开发人员一样,我不是大屏幕的粉丝,但大多数客户仍然需要它们,因为iPhone有它们或其他一些"很好"的理由.
在android指南中它说:
当然,您希望每个人都能快速学习绳索,发现很酷的功能,并充分利用您的应用程序.因此,您可能会在首次打开应用时向所有新用户展示一次性介绍性幻灯片,视频或启动画面.或者,当用户第一次与某些功能进行交互时,您可能会想到显示有用的文本气泡或对话框.
链接到这里,第一段"不要显示未经请求的帮助,除非在非常有限的情况下"
现在在材料设计指南中,他们建议开发人员使用"启动屏幕"
由于在显示空白画布的同时启动应用程序会增加其感知的加载时间,因此请考虑使用占位符UI或品牌启动屏幕.
我猜测android网站还没有更新.无论如何,Hangouts的最后一个版本(5.0.104 ...)有一个非常好的快速启动屏幕.它在我的带有Marshmallow的Nexus 5上即时显示.所以我的问题是,有一种"官方"方式吗?
我一直在寻找的例子,但无法找到除了有点像这个例子变通的东西在这里,它使用什么,我认为是一个闪屏活动最常用的方法.但是,在显示实际的启动画面之前,应用程序已被销毁时,会显示白屏.
这第二个示例使用了与被立刻显示,但几乎同样快消失的窗口背景主题.
那么,谷歌如何在Google Hangouts中制作启动屏幕,该屏幕会毫不拖延地显示,之前没有任何白屏?
我正在尝试使用ionic.io发送推送通知.这是我做的:
ionic.io仪表板中创建api令牌我在app.js中的源代码是由ionic start pushdemo生成的
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
var push = new Ionic.Push({
"debug": true
});
push.register(function(token) {
alert(token.token);
console.log("Device token:",token.token);
push.saveToken(token);
});
Run Code Online (Sandbox Code Playgroud)7.添加推送插件:
离子插件添加phonegap-plugin-push --variable SENDER_ID ="myproject_number"
我在myproject_number周围尝试了或不带引号.这是第1步中的项目编号.
8.将dev_push设置为false
9.通过离子io init将我的应用程序挂钩到ionic.io
10.Run 离子运行android -lc
找到以下错误消息:
它出什么问题了?有人可以帮忙吗?谢谢.
我想制作一个录音机应用程序,但当我单击“开始录音”按钮时它崩溃了。我在 android.media.MediaRecorder.start(Native Method) 处收到一条错误消息 java.lang.IllegalStateException。我还附上了日志。
package com.example.sahil.chuckit;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.os.Environment;
import java.io.File;
public class MainActivity extends Activity {
private static Button submit;
private static Button submit2;
private static Button submit3;
private static Button submit4;
private MediaPlayer mediaPlayer;
private MediaRecorder recorder;
private String output_file;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
output_file = Environment.getExternalStorageState() + "/audiorecorder.3gpp";
OnClickButtonListener();OnClickButtonListener1();
OnClickButtonListener3();OnClickButtonListener4();
}
public void OnClickButtonListener(){
submit =(Button)findViewById(R.id.button);
submit.setOnClickListener(
new View.OnClickListener() {
@Override …Run Code Online (Sandbox Code Playgroud) 我正在寻找使用Android手机提高位置采样率的方法。在SO每年大约一次询问如何获得更高的采样率。
但是我的问题更具体。通过使用新的原始GNSS测量,如果我使用原始数据并自己计算位置,是否有可能获得更高的采样率?
也许我误解了原始GNSS数据的要点,但是由于我的无知,我认为像Pixel 2这样的电话支持GPS,GLONASS,GALILEO,BeiDou和QZSS的数据在理论上应该比1Hz频率更频繁。但是它自己的芯片仅以1Hz的采样率计算并发送位置到系统。
但是,由于有来自五个定位系统的原始数据,因此不仅应该获得更高的采样率,而且应该具有更高的准确性。
所以我的问题是,是否有可能利用原始数据来获得更高的采样率和更好的准确性?仔细阅读上面的页面并没有太多建议,并且原始定位数据并不是我的专长。
我已经按照关于如何为Android实现谷歌游戏服务的教程,并最终得到了简单的谷歌+登录.我尝试了如何在我修复问题之前登录.现在我无法使用此帐户登录,但如果我使用其他帐户,我可以.
我从第一个帐户得到的错误是:
06-05 16:49:03.226: W/dqi(19754): Authentication error: Unable to respond to any of these challenges: {bearer=WWW-Authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=invalid_token}
06-05 16:49:03.226: E/Volley(19754): [4376] il.a: Unexpected response code 401 for https://www.googleapis.com/games/v1/players/115167649949168063107
06-05 16:49:03.515: W/dqi(19754): Authentication error: Unable to respond to any of these challenges: {bearer=WWW-Authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=invalid_token}
06-05 16:49:03.515: E/Volley(19754): [4376] il.a: Unexpected response code 401 for https://www.googleapis.com/games/v1/players/115167649949168063107
06-05 16:49:04.280: W/dqi(19754): Authentication error: Unable to respond to any of these challenges: {bearer=WWW-Authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=invalid_token}
06-05 16:49:04.280: E/Volley(19754): [4375] il.a: …Run Code Online (Sandbox Code Playgroud) android ×9
android-gnss ×1
google-maps ×1
gps ×1
gradle ×1
ionic.io ×1
javascript ×1
realm ×1
sqlite ×1
three.js ×1