我正在使用 Android Database Component Room,我想在 App Gradle 的依赖项中使用以下代码导出架构:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
javaCompileOptions{
annotationProcessorOptions{
arguments= ["room.schemaLocation":
"$projectDir/schemas".toString()]
}}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
//room
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
}
Run Code Online (Sandbox Code Playgroud)
但是我面临以下错误:
ERROR: Could …Run Code Online (Sandbox Code Playgroud) 当我为 SocketIO 运行烧瓶时,我在我的 cmd 上得到以下信息:
WARNING in __init__: Flask-SocketIO is Running under Werkzeug, WebSocket is not available.
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
我正在尝试截取增强现实屏幕的屏幕截图并将其作为位图传递给另一个活动。
这是我用来截取屏幕截图的代码:
截图功能
public static void tmpScreenshot(Bitmap bmp, Context context){
try {
//Write file
String filename = "bitmap.png";
FileOutputStream stream = context.openFileOutput(filename, Context.MODE_PRIVATE);
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
//Cleanup
stream.close();
bmp.recycle();
//Pop intent
Intent in1 = new Intent(context, CostActivity.class);
in1.putExtra("image", filename);
context.startActivity(in1);
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
接收截图功能
private void loadTmpBitmap() {
Bitmap bmp = null;
String filename = getIntent().getStringExtra("image");
try {
FileInputStream is = this.openFileInput(filename);
bmp = BitmapFactory.decodeStream(is);
ImageView imageView = findViewById(R.id.test);
imageView.setImageBitmap(Bitmap.createScaledBitmap(bmp, 120, 120, false));
is.close();
} …Run Code Online (Sandbox Code Playgroud) 从文档https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/Pose 我看到 Pose 意味着有一个不可变的锚点。但我不太确定它在以下代码中是如何工作的,其中在两点之间绘制一条线:
Pose point1;
// draw first cube
Pose point0 = getPose(anchors.get(0));
drawObj(point0, cube, viewmtx, projmtx, lightIntensity);
checkIfHit(cube, 0);
// draw the rest cube
for(int i = 1; i < anchors.size(); i++){
point1 = getPose(anchors.get(i));
log("onDrawFrame()", "before drawObj()");
drawObj(point1, cube, viewmtx, projmtx, lightIntensity);
checkIfHit(cube, i);
log("onDrawFrame()", "before drawLine()");
float distanceCm = ((int)(getDistance(point0, point1) * 1000))/10.0f;
drawLine(point0, point1, viewmtx, projmtx);
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释更多关于姿势的文档,因为文档让我更加困惑吗?
在对数据库模式进行了一些广泛的更改后,我运行了 makemigrations。它成功创建了迁移。但随后迁移失败:
AttributeError: 'str' object has no attribute '_meta'
这是我更改的代码。我将 Hardskills 的多对多模型从一张表拆分为 2 个不同的用户和作业表。
最初的
class Hardskills(models.Model):
user = models.ManyToManyField(User, related_name="user_hs",through="HardskillsProfile")
job = models.ManyToManyField(Job, related_name="job_hs",through="HardskillsProfile")
hardskills = models.CharField(max_length=100, db_index=True)
def __str__(self):
return self.hardskills
class HardskillsProfile(models.Model):
"""Through Model for Many to Many relationship for user/jobs and hardskills"""
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="user",null=True)
job = models.ForeignKey(Job, on_delete=models.CASCADE, related_name="job",null=True)
hardskills = models.ForeignKey(Hardskills, on_delete=models.CASCADE)
Run Code Online (Sandbox Code Playgroud)
修改后最终结果
from attributes.models import Category
from django.contrib.auth.models import User
from content.models import Job
from django.db import models
class Hardskills(models.Model):
user …Run Code Online (Sandbox Code Playgroud)