小编Lun*_*box的帖子

SQlite concat select语句

我想知道是否可以在SQlite中连接并添加空格.这就是我的意思:

SELECT NAME || SURNAME AS USER_NAME FROM USERS
Run Code Online (Sandbox Code Playgroud)

但是然后在查询中添加一些东西,让结果显示为:

Name Surname
Run Code Online (Sandbox Code Playgroud)

并不是

NameSurname
Run Code Online (Sandbox Code Playgroud)

在SQlite中这样的事情可能吗?

sqlite select

15
推荐指数
2
解决办法
3万
查看次数

Android添加边框以编程方式编辑文本

我使用这个例子并试图以编程方式将它添加到我的编辑文本中editText.setBackgroundResource(R.drawable.edit_text_back);,但它不起作用.我怎么能做到这一点?有什么建议或想法吗?

编辑 editText也是以编程方式定义的.

EditText editText = new EditText(this.getApplicationContext());
Run Code Online (Sandbox Code Playgroud)

我把它添加到表格行

受审

editText.setBackground(getResources().getDrawable(R.drawable.edit_text_back));
editText.setBackgroundDrawable(getResources().getDrawable(R.drawable.edit_text_back));
Run Code Online (Sandbox Code Playgroud)

编辑文本创建

TableRow row = (TableRow) findViewById(R.id.table_row_kind);
TableRow.LayoutParams rowP = new TableRow.LayoutParams();
        rowP.setMargins(10, 0, 0, 0);
editText = new EditText(this.getApplicationContext());
editText .setGravity(Gravity.FILL_HORIZONTAL);
editText .setLayoutParams(rowP);
editText .setFilters(new InputFilter[]{txtFilter});
editText.setBackground(getResources().getDrawable(R.drawable.edit_text_back));
Run Code Online (Sandbox Code Playgroud)

row.xml

<TableRow
    android:id="@+id/table_row_kind"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="5dip" >

    <TextView
       android:layout_width="250sp"
       android:text="Kind"
       android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)

android background-color android-edittext

12
推荐指数
2
解决办法
4万
查看次数

在android stdio中使用邮件,激活和其他jar文件时出现I/O错误

我在我的应用程序中使用邮件,激活和其他jar文件以编程方式发送电子邮件.实现这一目标的代码之前运行良好,但最近它只是停止工作.尝试从我的应用程序发送邮件时,我收到以下I/O错误:

06-06 09:41:33.596 19502-20337/neurosys.tgotracker W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error

                                                      [ 06-06 09:41:33.596 19502:20337 W/         ]
                                                      Unable to open '/system/framework/oem-services.jar': No such file or directory
06-06 09:41:33.596 19502-20337/neurosys.tgotracker W/art: Failed to open zip archive '/system/framework/oem-services.jar': I/O Error
06-06 09:41:33.621 19502-20337/neurosys.tgotracker W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error

                                                      [ 06-06 09:41:33.622 19502:20337 W/         ]
                                                      Unable to open '/system/framework/oem-services.jar': No such file or directory
06-06 09:41:33.622 19502-20337/neurosys.tgotracker W/art: Failed to open zip archive '/system/framework/oem-services.jar': I/O Error
06-06 …
Run Code Online (Sandbox Code Playgroud)

email android jar android-studio

8
推荐指数
0
解决办法
1749
查看次数

蓝牙连接汽车

我正在尝试检查我的设备何时与汽车相连.我认为这款车就像一个蓝牙耳机,因此我在我的活动onCreate中使用了以下代码:

    // Get the default adapter
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    BluetoothProfile.ServiceListener mProfileListener = new BluetoothProfile.ServiceListener() {
        public void onServiceConnected(int profile, BluetoothProfile proxy) {
            Time today = new Time(Time.getCurrentTimezone());
            today.setToNow();
            if (profile == BluetoothProfile.HEADSET) {
                mBluetoothHeadset = (BluetoothHeadset) proxy;

                LogginUtil.logString("BluetoothApp", "Headset event called at " + today.format("%k:%M:%S") + " - " + profile);
            } else {
                LogginUtil.logString("BluetoothApp", "Other event called at " + today.format("%k:%M:%S") + " - " + profile);
            }
        }
        public void onServiceDisconnected(int profile) {
            if (profile == BluetoothProfile.HEADSET) …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

6
推荐指数
1
解决办法
1449
查看次数

使用 MultiDexApplication 会导致 applicationContext 变为 null

我已按照此链接中的说明将我的应用程序切换到 MultiDexApplication - https://developer.android.com/studio/build/multidex.html

应用程序现在安装正确,但我的应用程序上下文为空。你们有没有经历过这样的事情?

如果您需要代码示例,请告诉我,但由于应用程序因无法获取应用程序上下文而崩溃,因此我想不出任何可以解释该问题的代码。

获取我的应用程序上下文如下:

TrackerApplication.getContext();


public class TrackerApplication extends MultiDexApplication {

private static Context context;

public TrackerApplication() {
    super();
    context = this;
}

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

@Override
public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
}

public static Context getContext() {
    return context;
}
}
Run Code Online (Sandbox Code Playgroud)

然后当我打电话时:

TrackerApplication.getContext().getSharedPreferences("MySettings",
            Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)

我得到一个空指针。我的应用程序上下文为空。

添加了一个测试来解释这个问题。在我的 Launch 活动中,我添加了以下代码:

if (TrackerApplication.getContext() == null) {
        Log.i("TEST", "Context is null");
    } else {
        Log.i("TEST", "What is the issue?");
    } …
Run Code Online (Sandbox Code Playgroud)

android android-multidex

6
推荐指数
1
解决办法
1382
查看次数

什么更快?一个intent.putExtras(捆绑带字符串)或许多intent.putExtra(字符串)?

什么更快?将一堆字符串值添加到a bundle然后将其添加到intent?或者只是将值添加到intent使用intent.putExtra()?或者它没有太大区别?

谷歌搜索给了我教程,但没有太多答案.只是出于好奇,想知道是否会影响使用其中一个的性能.很接近,但没有回答我想知道的事情.

performance android bundle android-intent

5
推荐指数
1
解决办法
1494
查看次数

谷歌驱动器Android API演示无法正常工作

我已经用这个问题拉了我的头发已经有一段时间了.我想将我的sqlite数据库上传到谷歌驱动器,然后下载它.问题是我在这里找到的驱动器演示不起作用.我需要获取DriveId并且我不知道如何,因为示例应用程序不起作用.我想Create a file in a folder.如果有任何工作教程,或我可以使用它一步一步,将不胜感激.我真的需要一些帮助才能让它发挥作用.

只是为了澄清,这就是我想要的:

任何人都可以告诉我如何获得DriveId,以便我可以让演示应用程序工作?如果这是不可能的,是否有任何一步一步的教程可以帮助我实现上传/下载文件夹中的文件?如果您需要什么,请告诉我

这是CreateFileInFolderActivity.class:

public class CreateFileInFolderActivity extends BaseDemoActivity {

    private DriveId mFolderDriveId;

    @Override
    public void onConnected(Bundle connectionHint) {
        super.onConnected(connectionHint);
        Drive.DriveApi.fetchDriveId(getGoogleApiClient(), EXISTING_FOLDER_ID)
                .setResultCallback(idCallback);
    }

    final private ResultCallback<DriveIdResult> idCallback = new ResultCallback<DriveIdResult>() {
        @Override
        public void onResult(DriveIdResult result) {
            if (!result.getStatus().isSuccess()) {
                showMessage("Cannot find DriveId. Are you authorized to view this file?");
                return;
            }
            mFolderDriveId = result.getDriveId();
            Drive.DriveApi.newContents(getGoogleApiClient())
                    .setResultCallback(contentsResult);
        }
    };

    final private ResultCallback<ContentsResult> contentsResult = new
            ResultCallback<ContentsResult>() {
        @Override …
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
1
解决办法
1605
查看次数

执行完成后关闭Realm实例

我想executeTransactionAsync在执行完毕后关闭我的Realm实例.原因是我的应用程序主线程一直在冻结,我认为它的原因是后台域实例在执行完成后没有被关闭.请参阅下面的代码:

realm.executeTransactionAsync(new Realm.Transaction() {
                    @Override
                    public void execute(Realm realm) {
                        // Execute realm code
                        realm.copyToRealmOrUpdate(myData);
                        // Can I close the realm instance here without getting an 
                        // error? realm.close(); causes an error.
                    }
                }, new Realm.Transaction.OnSuccess() {
                    @Override
                    public void onSuccess() {
                        Log.i("CB", "success");
                        // looks like I cannot access the execute Realm 
                        // instance here.
                        // Closing realm.getDefaultInstance does not change my issue
                    }
                }, new Realm.Transaction.OnError() {
                    @Override
                    public void onError(Throwable error) {
                        Log.i("CB", "error - …
Run Code Online (Sandbox Code Playgroud)

android realm

4
推荐指数
1
解决办法
1759
查看次数

Android viewpager以编程方式设置背景

我想知道如何以编程方式设置ViewPager背景?在xml中我可以像这样手动设置背景:android:background="@drawable/ic_launcher".我从SQLite数据库中获取一个uri 并将其转换为Bitmap.我想将其设置Bitmap为背景.这可能吗?

android bitmap android-viewpager

3
推荐指数
1
解决办法
1804
查看次数

舍入时间间隔最多15分钟

我有一个场景,用户可以按下按钮启动秒表,然后再次按下它来停止它.但是有一个转折 - 结束时间需要以15分钟的步长进行四舍五入.例如,如果开始时间是08:13结束时间08:16,则需要向上舍入到08:28.或者,如果间隔时间超过15分钟08:31,则需要四舍五入到08:43.

你们有没有任何关于如何解决这种情况的指示?如果我要求的内容过于复杂,我该如何向上和向下舍入到最近的15分钟(分别).

javascript

2
推荐指数
1
解决办法
657
查看次数

Dropbox sync/Google drive,如何上传sqlite数据库

我正在尝试将sqlite数据库文件上传到dropbox.这是我的代码:

public void uploadDb(){
    File public_db_file = null;
    try {
        public_db_file = writeDbToPublicDirectory();
    } catch (IOException e2) {
        e2.printStackTrace();
    }

    DbxFileSystem dbxFs = null;

    try {
        dbxFs = DbxFileSystem.forAccount(mAccount);
    } catch (Unauthorized e1) {
        e1.printStackTrace();
    }

    DbxFile testFile = null;
    try {
        testFile = dbxFs.create(new DbxPath("database_sync.txt"));
    } catch (InvalidPathException e1) {
        e1.printStackTrace();
    } catch (DbxException e1) {
        e1.printStackTrace();
    }
    try {
        testFile.writeFromExistingFile(public_db_file, false);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        testFile.close();
    }

}
Run Code Online (Sandbox Code Playgroud)

编辑(更多代码)

此函数将我的数据库从app私有目录复制到公共目录,以便我可以上传它:

private File …
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
5918
查看次数