小编Dav*_*vid的帖子

设备开启或解锁时启动应用程序

1.当设备刚刚打开时如何启动/打开应用程序?

2.当设备刚刚解锁/退出锁定状态时如何启动/打开应用程序?

(我的意思是,如何识别这些事件?)

10Q,

大卫

这是我的新代码:

在清单中:

<receiver
  android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
  android:name="BootReciver" >
  <intent-filter >
      <action android:name="android.intent.action.BOOT_COMPLETED" />
      <action android:name="android.intent.action.SCREEN_ON" />
  </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

在BootReciver.java中,我添加到了我的项目中:

package development.Grandpa;
import android.content.BroadcastReceiver;

    public class BootReciver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        Intent intent1 = new Intent(context, Grandpa.class);
        context.startActivity(intent1);      
    }
}
Run Code Online (Sandbox Code Playgroud)

爷爷班是我的主要活动.

另外,我正在我的设备上直接运行代码,这就是我在LogCat中得到的:

?? - ?? ??:??:??.???:INFO /():无法打开日志设备'/ dev/log/main':没有这样的文件或目录

我还尝试添加一个reciver用于启动,另一个用于ScreenOn(有两个类),如下所示:

<receiver
android:name="ScreenOnReciver" >
    <intent-filter >
    <action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>

<receiver
android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:name="BootReciver" >
<intent-filter >
    <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
 </receiver>
Run Code Online (Sandbox Code Playgroud)

但它也没有帮助.

编辑: …

events android

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

从http get请求中读取非英语字符

我在从http获取请求中获取希伯来字符时遇到问题.

我得到这样的正方形字符:"[]"而不是希伯来字符.

英文字符很好.

这是我的功能:

public String executeHttpGet(String urlString) throws Exception {
    BufferedReader in = null;
    try {
        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(new URI(urlString));
        HttpResponse response = client.execute(request);
        in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),"UTF-8"));
        StringBuffer sb = new StringBuffer("");
        String line = "";
        String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
            sb.append(line + NL);
        }
        in.close();
        String page = sb.toString();
        // System.out.println(page);
        return page;
    } finally {
        if (in != null) {
            try …
Run Code Online (Sandbox Code Playgroud)

java android httprequest hebrew

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

如何在Motorola Xoom上进行屏幕截图?

我想在摩托罗拉Xoom上拍摄一个屏幕截图.

在三星Galaxy SI中你可以通过以下方式实现:

开始按HOME并立即按BACK.

在三星Galaxy S-II/III中你可以通过以下方式实现:

开始按HOME并立即按OFF/Lock按钮.

但是我怎么能在摩托罗拉Xoom上做到这一点(不使用Eclipse工具)?

android screen-capture motorola xoom samsung-mobile

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

从parseObject获取文件

这是一个较少的Android问题和更多Parse.com问题,但我需要你的帮助:

我在Parse.com的应用程序表中有一个图像文件

文件还可以,我可以手动下载并观看.

但是当我试图使用我从服务器获得的parseObject来获取它时,我得到"null"

码:

  byte[] imageFile = parseObject.getBytes(Statics.COL_IMAGE_FILE);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

ps:我可以在parseObject"estimatedData"字段中看到图像文件数据/链接,但无法得到他.

android file parse-platform

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

获取Parse.com图像文件的链接

我的表中有File列.

该文件代表图像.

文件没问题,我可以把它作为字节数组.

我可以获得此图像的直接(网络)链接吗?

android image file parse-platform

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

具有setStartOffset的AnimationSet无效

我试图在一个视图上运行一些动画(一个接一个) AnimationSet

从规模1 --> 0和比0 --> 1

AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());

ScaleAnimation animation1 = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation1.setDuration(500);

ScaleAnimation animation2 = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation2.setDuration(500);
animation2.setStartOffset(500);

animationSet.addAnimation(animation1);
animationSet.addAnimation(animation2);

mFloatingActionButton.startAnimation(animationSet);
Run Code Online (Sandbox Code Playgroud)

视图刚刚消失,一秒后再次出现.没有动画.

如果我删除setStartOffset(...)我可以看到动画,但不是我想要的那个.

我在这里错过了什么?

animation android scale android-animation

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

简单登录统一c#脚本

它应该很简单,但仍然无法找到一个直接的答案:

如何使用C#Unity脚本记录简单消息?

我试过这个:

Debug.Log("Hello Log");
Run Code Online (Sandbox Code Playgroud)

它不起作用或我没有找到正确的地方.

c# logging unity-game-engine

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

Facebook分享中的错误图像 - 使用共享意图时

我正在使用下一代码来支持我的应用程序中的共享:

//create the send intent  
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);  

//set the type  
shareIntent.setType("text/plain");  

//add a subject  
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject");  

String msg = https://play.google.com/store/apps/detailsid=com.rovio.amazingalex.premium

//add the message  
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg);  

//start the chooser for sharing  
startActivity(Intent.createChooser(shareIntent, "Sharing..."));  
Run Code Online (Sandbox Code Playgroud)

即使没有任何额外的图像从我身边,

Facebook采用随机图像,这不是我的应用程序的一部分,但与它有关联.

例如,在尝试分享"Amazing Alex"时,这是附加图像:

在此输入图像描述

我该如何更改此图片?

android share facebook android-intent

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

如何设置Gridview的文本颜色

我可以更改背景颜色,但是如何更改Gridview内容的文本颜色?

android gridview colors

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

Android:在按钮中设置文本自动大小

在Android中哪里可以设置文本过长时自动缩小尺寸?

使用android:autoText="true"不行。

android button

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

Android Studio无法识别checkSelfPermission

是否可以运行Google Sample - RuntimePermissionsBasic

在OS低于MNC(Android M)的设备上?

该项目附带:

compileSdkVersion "android-MNC"
targetSdkVersion "MNC"
Run Code Online (Sandbox Code Playgroud)

到目前为止一直这么好,在低于M OS的情况下运行它将获得:

INSTALL_FAILED_OLDER_SDK

但当我把它改为:

compileSdkVersion 22
targetSdkVersion "MNC"
Run Code Online (Sandbox Code Playgroud)

Android Studio无法识别该checkSelfPermission (...)方法

permissions android android-6.0-marshmallow

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

使用Retrofit 2将根单个元素添加到xml

我在xml中有一个服务器响应,该响应格式不正确,也没有根元素:

<option value="stationAValue">stationADescription</option>
<option value="stationBValue">stationBDescription</option>
Run Code Online (Sandbox Code Playgroud)

我试图这样使用SimpleXmlConverterFactory

Retrofit retrofit = new Retrofit.Builder()
    .baseUrl(Params.BASE_URL)
    .client(okHttpClient)
    .addConverterFactory(SimpleXmlConverterFactory.create())
    .build();
Run Code Online (Sandbox Code Playgroud)

这是我的类,代表一行:

public class Station {
    @Element(name = "option")
    private String mName;

   @Attribute(required = false)
   private String value;
}
Run Code Online (Sandbox Code Playgroud)

但是,当然,如果没有根元素就无法解析它,是否有一种方法可以在SimpleXmlConverterFactory尝试解析响应之前添加根元素?

还是另一种解决方案?

xml android retrofit2 simple-xml-converter

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

以编程方式调用按钮上的onClick()

听起来很简单,但我需要一些帮助

我有一个Button我想用代码触发的东西.

我已经onClick()在此按钮上附加了一项功能:

在此输入图像描述

我怎么能以编程方式触发它?

c# onclick button unity-game-engine

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