小编My *_*God的帖子

Rails i18n如何获取某个键的所有值?

在Rails i18n中,如何使用以下内容获取某个键的所有值:

translations = I18n.backend.send(:translations)
Run Code Online (Sandbox Code Playgroud)

得到所有的钥匙

我需要能够获得某个部分,例如只返回"home"下的所有内容

en:
  home:
    test: test
Run Code Online (Sandbox Code Playgroud)

key key-value ruby-on-rails-3 rails-i18n

10
推荐指数
2
解决办法
4881
查看次数

Android 4.4管理器中未列出Android 4.4(KITKAT)API LEVEL 19

显而易见的Android 4.4 ( KITKAT ) API Level: 19是现在可用.

我只想更新到最新的API级别,然后更改android:targetSdkVersion="19" 清单文件.

我点击Android SDK Manager使用Eclipse Java EE IDE for Web Developers具有Version: Helios Service Release 2.

Android SDK Manager已打开,但我没有Android API Level: 19在Packages列表中找到.

此外,我看到其他SO帖子提到如果您Tools -> Options在Android SDK Manager中清除缓存并重新加载Android SDK Manager,那么您将在包中列出此API.

我做了同样但没有运气.

截图如下 -

在此输入图像描述

eclipse android android-manifest

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

具有相同代码库的不同名称的多个应用程序

阅读这篇文章,想到了同样的问题 - 一个代码库,两个Android应用程序

我已经创建了一个应用程序testApp具有相似的项目topics,splash screens,logos,charts,rules,statuses和/或events.

现在,我想不同的应用程序(testApp_USA,testApp_Canada,testApp_Australia从相同的代码库),并把它们在谷歌Play商店,这样,如果用户下载的应用程序,比方说,testApp_USA,那么只有特定的项目该区域应该显示像美国的闪屏,美国标志等.

所以我想根据国家/地区配置多个应用程序,然后根据用户下载的应用程序将项目设置为默认值.

目前,我有一个适用于所有地区的单一申请,并且我根据地区强加了多个条件来区分或更改项目.

例如:

(在许多Java文件中,我使用过)

if(rule.contains("USA"))
{
 //Show splash screen of USA
}
Run Code Online (Sandbox Code Playgroud)

(同样,在许多Java文件中,我使用过)

if(rule.contains("Australia"))
{
 //Show splash screen of Australia
}
Run Code Online (Sandbox Code Playgroud)

这只是整个代码中重复的一项内容.考虑到所有,它会更多.

应该有更好的方法在Android中使用不同的名称和设置创建多个应用程序.

我知道,iOS允许我轻松更改应用程序名称和配置文件以允许创建多个应用程序.但我不知道或者这对Android代码不容易.

我的问题:

是否可以使用不同的项目设置在Android中创建具有相同源代码的不同应用程序并将其发布到Google Play商店?如果,如何设置此类配置?

更新:

阅读本文 - 多个android-application-package-apk-files-from-single-source-code

然后我提出了同样的想法 -

1)获取一些字符串变量,该变量包含您要创建的应用程序类型的值.

public static final String app_Name …
Run Code Online (Sandbox Code Playgroud)

android app-config application-settings apk google-play

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

获取蓝牙适配器时的Lint错误

我正在关注Bluetooth Low Energy设备的文档以扫描BLE设备.

正如文档中所提到的,我定义了---

BluetoothAdapter mBluetoothAdapter = null;

final BluetoothManager bluetoothManager = 
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

mBluetoothAdapter = bluetoothManager.getAdapter(); //Lint Error..
Run Code Online (Sandbox Code Playgroud)

但是我得到了一个Lint错误---

调用需要API级别18(当前最小值为8):android.bluetooth.BluetoothManager#getAdapter

所以我改变了我的代码 -

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Run Code Online (Sandbox Code Playgroud)

代码是否替换上述lint错误?

android bluetooth-lowenergy android-bluetooth

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

在android清单中使用CATEGORY_HOME的目的?

从AndroidManifest中删除以下内容的替代方法是什么:

 <activity           

    android:name="com.apper.main.UserActivity"
    android:label="@string/app_name"        
    android:launchMode="singleTask"
    android:clearTaskOnLaunch="true"
    android:stateNotNeeded="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
 </activity>
Run Code Online (Sandbox Code Playgroud)

我还发现删除上面的行后,对我的android应用程序没有任何影响.这个类别的主要用途是什么,它的替代方案是什么.

如果此类别的目的是启动主屏幕,则可以通过以下方式完成:

Intent homeIntent= new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);
Run Code Online (Sandbox Code Playgroud)

以上代码将启动主屏幕,但为什么android中的行显示?从这里删除线路的目的是什么,没有改变应用程序?

android android-manifest

6
推荐指数
2
解决办法
7769
查看次数

由于依赖于bundle org.eclipse.core.runtime 3.8.0,无法在eclipse中安装插件

我在为eclipse 安装Genymotion插件时遇到连续失败的安装问题.

错误日志显示" 它需要包org.eclipse.core.runtime 3.8.0 ".

错误日志:

Cannot complete the install because one or more required items could not be found.
  Software being installed: Genymotion Eclipse Tools 1.0.1.201307161043 (com.genymobile.genymotion.ide.eclipse.feature.group 1.0.1.201307161043)
  Missing requirement: Genymotion 1.0.1.201307161043 (com.genymobile.genymotion.ide.eclipse.plugin 1.0.1.201307161043) requires 'bundle org.eclipse.core.runtime 3.8.0' but it could not be found
  Cannot satisfy dependency:
    From: Genymotion Eclipse Tools 1.0.1.201307161043 (com.genymobile.genymotion.ide.eclipse.feature.group 1.0.1.201307161043)
    To: com.genymobile.genymotion.ide.eclipse.plugin [1.0.1.201307161043]
Run Code Online (Sandbox Code Playgroud)

plugins android emulation genymotion

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

HttpURLConnection GET调用参数不起作用

我有一个非常简单的代码,无法正常工作.

HttoCon类:

package test;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class HttpCon {


public static void main(String[] args) {
    try {
        sendGet();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
    // HTTP GET request
        private static void sendGet() throws Exception {

            String url = "http://myweb.com/public/resource/data/stream";

            URL obj = new URL(url);
            HttpURLConnection con = (HttpURLConnection) obj.openConnection();

            // optional default is GET
            con.setRequestMethod("GET");


            //add request header
            con.setRequestProperty("begin", "1430295300000");
            con.setRequestProperty("end", "1430297279988");
            con.setRequestProperty("id", "140621");
            con.setRequestProperty("time", …
Run Code Online (Sandbox Code Playgroud)

java url httpurlconnection

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

设计 send_reset_password_instructions 不起作用

我在控制器中添加一个功能,唯一的目标是通过 API 请求触发忘记密码过程。

这是reset_password方法-

  def reset_password
    @user = User.find_by_email(params[:email])
    @user.send_reset_password_instructions
    respond_to do |format|
      format.xml  { render :xml => user_api_ressource(@user, :xml)}
      format.json  { render :json => user_api_ressource(@user, :json)}
    end
  end
Run Code Online (Sandbox Code Playgroud)

我收到带有重置密码链接的邮件,它会打开一个页面,我可以在其中设置新密码,但当我提交表单时,它说令牌无效。

我正在使用 sendgrid 发送电子邮件。我认为这不是令牌截断问题。

我正在使用最新版本的 devise 在 Heroku cedar 上运行 Rails 应用程序。

任何想法 ?

ruby-on-rails heroku devise

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

从IntentService调用AsyncTask的问题

我已经创建了IntentService类和执行asyncTaskonPreExecute()在此代码行调用时获得异常pDialog.show();

AsyncHandlerService类---

public class AsyncHandlerService extends IntentService{
ProgressDialog pDialog;
HttpPost post;
HttpResponse response;
Context ctx;

public AsyncHandlerService() {
    super("AsyncHandlerService");
    ctx = this;
}

@Override
protected void onHandleIntent(Intent intent) {
    new LoadDeviceInfo().execute();   
}


class LoadDeviceInfo extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    super.onPreExecute();
    pDialog = new ProgressDialog(ctx);
    pDialog.setMessage("Updating device info...");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.show(); //Exception here..
}

protected String doInBackground(String... args) {
}

protected void onPostExecute(String file_url) {
    pDialog.dismiss();
}
Run Code Online (Sandbox Code Playgroud)

更新:

我 …

android android-service android-asynctask android-intentservice

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

通过SPP配置文件进行GATT蓝牙通信?

这让我困惑了好几天。

在开始实现功能时,我使用GATT配置文件 进行BLE蓝牙通信。

然后我想出了BluetoothSocket。这使用SPP配置文件进行蓝牙通信。

有提到:

蓝牙套接字最常见的类型是RFCOMM,这是Android API支持的类型。RFCOMM是通过蓝牙进行的面向连接的流传输。也称为串行端口配置文件(SPP)。

我的要求是-

1)扫描然后使用BLE蓝牙将我的android设备与黑匣子连接。

2)然后开始通讯。字节将在两者之间发送。

有任何想法吗 ?

android bluetooth-lowenergy android-bluetooth

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