我有一个名为 SingleTouchTest 的简单 Activity 来理解屏幕触摸。奇怪的是 SingleTouchTest 以我所处的任何方向启动,但旋转设备不会导致屏幕旋转。
我的测试设备是运行 Android 4.0.3 的 Acer A100。
主要的 Activity 包含一个 ListView,它导航到我的测试 Activityes,包括 SingleTouchTest。除了旋转之外,我可以毫无问题地运行 SingleTouchTest(下面的完整代码)。在 AndroidManifest.xml(下面的完整代码)中,我尝试了所有的组合
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="unspecified"
它不会自动旋转。我什至从 SingleTouchTest 中删除了 onConfigurationChanged() 方法,但没有任何反应。
AndroidManifest.xml的完整代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.Bespoke.AndroidBasics"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="preferExternal" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:icon="@drawable/ic_launcher"
android:label="Android Basics">
<activity
android:name=".AndroidBasicsStarter"
android:label="Android Basics"
android:screenOrientation="unspecified">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LifeCycleTest"
android:label="Life Cycle Test"
android:configChanges="keyboard|keyboardHidden|orientation" android:screenOrientation="unspecified"/>
<activity
android:name=".SingleTouchTest"
android:label="Single Touch Test"
android:configChanges="keyboard|keyboardHidden|orientation" android:screenOrientation="unspecified"/>
<activity
android:name=".MultiTouchTest"
android:label="Single Touch Test"
android:configChanges="keyboard|keyboardHidden|orientation" android:screenOrientation="unspecified"/>
<activity
android:name=".KeyTest"
android:label="Key Test" android:screenOrientation="unspecified"/>
</application>
</manifest>
SingleTouchTest 的完整代码:
package com.Bespoke.AndroidBasics;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TextView;
public class SingleTouchTest extends Activity
implements OnTouchListener {
StringBuilder builder = new StringBuilder();
TextView textView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setText("Touch and drag (one finger only!)");
textView.setOnTouchListener(this);
this.setContentView(textView);
}
public boolean onTouch(View v, MotionEvent event) {
builder.setLength(0); // clear the builder
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
builder.append("down, ");
break;
case MotionEvent.ACTION_MOVE:
builder.append("move, ");
break;
case MotionEvent.ACTION_CANCEL:
builder.append("cancel, ");
break;
case MotionEvent.ACTION_UP:
builder.append("up, ");
break;
}
builder.append(event.getX());
builder.append(", ");
builder.append(event.getY());
String text = builder.toString();
Log.d("TouchTest", text);
textView.setText(text);
return true; // Consume the event, if false super.onTouch superceeds us
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
最佳答案
因为你正在使用
android:screenOrientation="unspecified"
对于每个 Activity ,它根据谷歌定义为
The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
这让我觉得设备出于某种原因正在声明所需的方向。也许尝试将屏幕方向切换为
android:screenOrientation="fullSensor"
这应该使它脱离特定设备的控制。
关于Android 方向变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10974126/
在启用Rack::Deflater来gzip我的响应主体时偶然发现了一些奇怪的东西。也许我遗漏了一些东西,但启用此功能后,响应被压缩,但是资源的ETag在每个请求上都会发生变化。这会强制应用程序每次都响应,而不是发送304。这在没有启用Rack::Deflater的情况下有效,我已经验证页面源没有改变。我正在运行一个使用thin作为Web服务器的Rails应用程序。Gemfile.lockhttps://gist.github.com/2510816有没有什么方法可以让我从Rack中间件获得更多的输出,这样我就可以看到发生了什么?提前致谢。 最佳答案
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我有两个具有以下格式的哈希mydetails[x['Id']]=x['Amount']这将包含如下数据hash1={"A"=>"0","B"=>"1","C"=>"0","F"=>"1"}hash2={"A"=>"0","B"=>"3","C"=>"0","E"=>"1"}我期待这样的输出:Differencesinhash:"B,F,E"非常感谢任何帮助。 最佳答案 这个解决方案可能更容易理解:(hash1.keys|hash2.keys).select{|key|hash1[key]!=hash2[key]}Array#|返回2
标题说明了一切。请注意,这不是模型或初始值设定项的更改。我可以删除Controller中的一个实例变量(例如,@user),然后重新加载一个View,它会工作-直到我重新启动服务器,在这种情况下它会提示变量为nil。我正常工作,然后切换到一组完全不同的Controller和View上工作,现在它无缘无故地发生了。应用处于开发环境中。development.rb内容:Dashboard::Application.configuredoconfig.cache_classes=falseconfig.whiny_nils=trueconfig.consider_all_requests_l
运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid
查看原文>>>基于”PLUS模型+“生态系统服务多情景模拟预测实践技术应用目录第一章、理论基础与软件讲解第二章、数据获取与制备第三章、土地利用格局模拟第四章、生态系统服务评估第五章、时空变化及驱动机制分析第六章、论文撰写技巧及案例分析基于ArcGISPro、Python、USLE、INVEST模型等多技术融合的生态系统服务构建生态安全格局基于生态系统服务(InVEST模型)的人类活动、重大工程生态成效评估、论文写作等具体应用基于ArcGISPro、R、INVEST等多技术融合下生态系统服务权衡与协同动态分析实践应用 本文从数据、方法、实践三方面对生态系统服务多情景预测进行讲解。内容涵盖多
1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La
我一直在调试网站以查找页面加载时间过长的根源,并将其缩小为用于从文本中提取URL的正则表达式:/(?:([\w+.-]+):\/\/|(?:www\.))[^\s在一大块文本上运行大约需要3秒。我发现如果我将第一个子句的逆语句添加到正则表达式((?:[^\w+.-]|^))的开头,它几乎会立即运行:/(?:[^\w+.-]|^)(?:([\w+.-]++):\/\/|(?:www\.))[^\s在我看来,添加的子句根本不应该影响正则表达式,因为没有什么可以导致该子句失败(因为这些字符将与“[\w+.-]++”子句匹配)。为什么这会使正则表达式运行得更快?编辑有些人要求提供我正在尝试做的
我们在最新项目中使用sunspot进行搜索。我们还使用devise并按如下方式为我们的用户模型编制索引:searchabledotext:fnametext:lnametext:emailtext:descriptiontext:twitter_usernameend使用此设置,除非solr正在运行,否则用户甚至无法登录。这意味着在每次保存用户模型时,都会与我们的solr服务器进行一些通信(重建索引?),即使可搜索字段都没有更改。这是正确的吗?我们还有许多其他模型正在被sunspot索引,这些模型具有经常更新的不可搜索字段。似乎sunspot正在为所有这些更新重新编制索引。有没有办法将
我有一个pdf文件。我想将其所有页面向右旋转90度。如何使用Prawngem实现此目的?当我尝试使用现有的pdf作为模板并尝试对其进行旋转时,它不起作用。我徒劳地尝试了以下。require'prawn/core'require'prawn/layout'require'prawn/measurement_extensions'pdf=Prawn::Document.new(:page_size=>[4.in,6.in],:template=>'orig.pdf',:layout=>'potrait')do|p|p.rotate(90)endpdf.render_file("./test