小编Al *_*ath的帖子

无法以读/写模式打开数据库

我收到以下错误:

不是错误(代码0):无法以读/写模式打开数据库.

我已经添加了

 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud)

我正在尝试在SD卡中存在的数据库中输入数据,我能够通过"OPEN_READONLY"读取数据库中已存在的数据.使用"OPEN_READWRITE"时出错

android android-sqlite

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

如何在SQL Server中创建涉及2个数据库的数据库图?

是否可以在同一SQL Server项目中创建涉及两个数据库的数据库图表?我在一个数据库中有一个表,我想为另一个数据库中的另一个表创建一个外键.

我正在使用MS SQLServer 2008 R2.

sql-server sql-server-2008 database-diagramming database-diagram

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

Android项目中的.DS_Store

当我开发Android应用程序时,我在Windows和OS X之间切换(在同一个应用程序上),以便.DS_StoreOS X创建的文件出现在Windows中.对于Git,我可以添加.DS_Store到忽略文件,所以没有问题.但是,确实.DS_Store使它成为apk文件(因此增加了apk文件的大小)?

android apk

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

在 AlertDialog.Builder 中设置文本格式

我无法让 AlertDialog 中的文本以粗体或斜体显示。

我尝试过直接格式化,也尝试过使用Android 字符串资源页面中的 CharSequence 实用程序,但我总是只得到纯文本。
我究竟做错了什么?

MyFragment.java

String idFormatted = String.format(resources.getString(R.string.id));
CharSequence idStyledText = Html.fromHtml(idFormatted);

CharSequence nameItalic = Utilities.italic(resources.getString(R.string.name));

String typeFormatted = String.format(resources.getString(R.string.type));
CharSequence typeStyledText = Html.fromHtml(idFormatted);

AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setPositiveButton("Dismiss",
        new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).setIcon(android.R.drawable.ic_dialog_info);

builder.setMessage( idFormatted + myData.getId() + "\t\t" +  nameItalic + myData.getName() + "\t\t" +  typeFormatted + myData.getType() );   
Dialog dialog = builder.create();
dialog.setTitle("Details");
dialog.show();        
Run Code Online (Sandbox Code Playgroud)

字符串.xml

<string name="id"><i>Id: </i></string>
<string name="name"><i>Name: </i></string> …
Run Code Online (Sandbox Code Playgroud)

android android-dialog

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

订阅导航抽屉到Observable

我想通过订阅Observable从数据库获取数据来填充导航抽屉,并在完成后通知订阅者(使用RxJava).我已经做了类似于Subscriber扩展的类Fragment,但不同之处在于导航抽屉不是一个单独的片段,而是在MainActivity中定义.

如何订阅的Navigation DrawerObservable

MainActivity.java

private DrawerLayout mDrawerLayout;
private ListView mDrawerList;

@Override
public void onStart() {                                                                                                                       mLoadAndStoreDataObservable = Observable.create(
    super.onStart();                                                                                                                              new Observable.OnSubscribe<String>() {

    // fragment creation code was here

    // populates a String[] myStringArray for Navigation Drawer                                                                                                                                                                  permitsSQLiteManager.addLogLine(mActivity, logString);
    if (!skipRestfulServiceCall) {
        getDataFromRestfulService();                                                                                                                      }
    }                                                                                                                                                     catch (Exception e) {
    else {  // get data from SQLite                                                                                                                           Log.e("loadAndStoreData  ", "Exception: " + e.getMessage());
        getDataFromSQLite();                                                                                                                                  mProgressDialog.dismiss();
    }                                                                                                                                                     }
                                                                                                                                                      }
    mTitle = …
Run Code Online (Sandbox Code Playgroud)

android observable navigation-drawer rx-java

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

不推荐使用getPreferenceManager

我正在为Android制作动态壁纸.我有墙纸部分工作,我正在尝试添加设置.在LiveWallpaperSettings我有这个:

@Override
protected void onCreate(Bundle icicle)
{
    super.onCreate(icicle);
    getPreferenceManager().setSharedPreferencesName(LiveWallpaperService.SHARED_PREFS_NAME);
    addPreferencesFromResource(R.string.livewallpaper_settings);
    getPreferenceManager().getSharedPreferences()
            .registerOnSharedPreferenceChangeListener(this);
}
Run Code Online (Sandbox Code Playgroud)

编译器说getPreferenceManager()并且addPreferencesFromResource()已弃用.我应该用什么呢?

这些方法来自 PreferenceActivity

[编辑]:基于迄今为止的一些评论,我显然正在使用过时的方法.有人能指出使用PreferenceFragments的LiveWallpaper代码的当代示例吗?

https://github.com/falsedmitri/LiveWallpaperTest.git

android

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

向上滚动时,Android工具栏不会展开

我有一个工具栏,当RecyclerView向下滚动时会折叠,但是当用户快速向上滚动时,工具栏不会展开.知道什么是错的吗?

此视频中显示了此行为:https://youtu.be/67ntPkW-5XA

布局代码:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    android:clickable="true"
    android:onClick="showText"
    android:src="@drawable/ic_done_white_24dp"
    app:borderWidth="0dp" />
Run Code Online (Sandbox Code Playgroud)

android material-design android-design-library

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

无法启动应用程序

我无法让我的应用程序从Visual Studio 2015/Xamarin运行Android设备.它无法在设备上启动,给出以下消息:

The application could not be started.
Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).  
Additionally, check Build->Configuration Manager to ensure this project is set to Deploy for this configuration.
Run Code Online (Sandbox Code Playgroud)

所以我将装饰器添加[Activity(MainLauncher = true)]到MainActivity中.

我检查了一下,检查了Build-> Configuration ManagerAnyCPU,Build和Deploy.

重新启动,相同的结果,没有在设备上启动并给出相同的消息.

StackOverflow上帖子表明之前的应用程序可能尚未完全删除,因此从adb shell发出以下命令:

adb -s 09103e9 shell pm list packages 
Run Code Online (Sandbox Code Playgroud)

显示设备上的包:

package:com.google.android.ears
package:com.android.launcher
package:com.android.defcontainer
package:com.rovio.popcorn
package:com.nuance.xt9.input
package:com.google.android.exchange
package:com.android.providers.partnerbookmarks
package:com.android.contacts
package:com.google.android.nfcprovision
package:com.android.phone
package:com.android.calculator2
package:com.android.htmlviewer
package:com.google.android.gsf.login …
Run Code Online (Sandbox Code Playgroud)

android xamarin.android xamarin

5
推荐指数
2
解决办法
4836
查看次数

所选证书对于编码签名无效

我有以下 Powershell 脚本来为 C# 应用程序创建新证书:

$expirationDate = [datetime]::Today.AddYears(5)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $expirationDate).Thumbprint
$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\" 
$filename = "mycert.pfx"
$pathAndFilename = $destinationDirectory + $filename
Export-PfxCertificate -cert "cert:\localmachine\my\$thumb" -FilePath $pathAndFilename -Password $SSpwd
Run Code Online (Sandbox Code Playgroud)

它运行良好。然后在 Visual Studio 的应用程序中,在项目属性页面的“签名”选项卡上,单击“从文件中选择”并浏览到该文件,我得到:

所选证书对于编码签名无效。选择另一个证书文件。

我究竟做错了什么?

显示现有证书的“签名”选项卡的屏幕截图

根据@ConnorLSW 评论添加信息。我现在有这个脚本:

$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\" 
$filename = "mycert.pfx"
$pathAndFilename …
Run Code Online (Sandbox Code Playgroud)

powershell clickonce certificate

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

使用系统密码进行身份验证

我找不到能够让我利用用户在Android设备上设置的用于在我的应用中进行身份验证的密码/密码/模式的API。

我可以使用一个指纹身份验证API来要求Android对用户进行身份验证,但是没有密码API可以使用密码/密码/模式代替指纹。

有没有一种方法可以要求Android根据用户已经设置的密码/密码/模式在我的应用中进行身份验证?

authentication android

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