我正在启动一个打电话的活动,但当我按下"结束通话"按钮时,它不会返回我的活动.您能否告诉我如何在按下"结束通话"按钮时启动回复给我的通话活动?这就是我拨打电话的方式:
String url = "tel:3334444";
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用recylerview,每当将新元素添加到recyclerview时,它就会使用滚动到最后一个元素
recyclerView.scrollToPosition(adapter.getCount());
Run Code Online (Sandbox Code Playgroud)
但是,每当键盘打开时(因为editTextView),它会调整视图大小并且recyclerview变小,但无法滚动到最后一个元素.
android:windowSoftInputMode="adjustResize"
Run Code Online (Sandbox Code Playgroud)
我甚至尝试使用以下代码滚动到最后一个元素,但它不起作用
editTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
recyclerView.scrollToPosition(chatAdapter.getItemCount());
}
}
});
Run Code Online (Sandbox Code Playgroud)
我可以尝试adjustPan将平移向上移动,但它隐藏了我的工具栏.请提出任何解决问题的方法.
我在我的应用程序中为每个活动使用自定义标题视图.在其中一个活动中,基于按钮点击,我需要更改自定义标题视图.现在,每当我调用setFeatureInt时,这都可以正常工作.
但是,如果我尝试更新自定义标题中的任何项目(例如更改按钮的文本或标题上的文本视图),则不会进行更新.
通过代码调试显示文本视图和按钮实例不为空,我还可以看到自定义标题栏.但文本视图或按钮上的文本未更新.还有其他人遇到过这个问题吗?我该如何解决?
谢谢.
编辑
这是我尝试过的.即使在调用postInvalidate时也不会更新.
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.text_title);
TextView databar = (TextView) findViewById(R.id.title_text);
databar.setText("Some Text");
databar.postInvalidate();
Button leftButton = (Button) findViewById(R.id.left_btn);
leftButton.setOnClickListener(mLeftListener);
leftButton.setText("Left Btn");
leftButton.postInvalidate();
Button rightBtn = (Button) findViewById(R.id.right_btn);
rightBtn.setOnClickListener(mRightListener);
rightBtn.postInvalidate();
Run Code Online (Sandbox Code Playgroud) 我正在使用Context来访问WifiManager和BluetoothManager等系统级服务.如何使用Mockito模拟这个getApplicationContext()?
我在Android Studio中遇到了gradle构建错误,如下所示:
Error:A problem occurred configuring project ':MyApp'.
Could not resolve all dependencies for configuration ':MyApp:classpath'.
Could not resolve io.fabric.tools:gradle:1.+.
Required by:
sw-android:MyApp:unspecified
Failed to list versions for io.fabric.tools:gradle.
Unable to load Maven meta-data from
https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml.
Could not GET 'https://repo1.maven.org/maven2/io/fabric/tools/gradle/maven-metadata.xml'.
peer not authenticated
Failed to list versions for io.fabric.tools:gradle.
Unable to load Maven meta-data from
http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml.
Could not GET http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml'.
peer not authenticated
Run Code Online (Sandbox Code Playgroud)
我发现"https"标签无法下载Maven URL,所以我在我的build.gradle文件中将https更改为http.此外,我检查了所有gradle设置并手动修改路径C:\ Users\Ashfaque1.AndroidStudio\config\options \中的other.xml文件,但仍然采用https://repo1.maven.org/maven2/io /fabric/tools/gradle/maven-metadata.xml.此外,一旦我点击浏览器的这个链接,我得到404异常,但错误的第二个URL http://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml,我能够成功点击并在我的系统中正确下载元数据文件.无法理解问题所在,我需要更改设置以便下载元数据文件.请建议我是否需要更改任何设置或更改此URL的位置 https://repo1.maven.org/maven2//io/fabric/tools/gradle/maven-metadata.xml
我的build.gradle文件如下:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric' …Run Code Online (Sandbox Code Playgroud) 我正在研究跟踪用户行踪的应用程序.为了节省电池,我想实现一个空闲区域,使位置管理器在GPS位置上拉低频率(甚至停止).一旦用户再次开始移动(通过加速度计和/或显着移动检测到),位置服务将拉出默认间隔.
一种方法是将空闲区域定义为minDistance参数LocationManager::requestLocationUpdates,但此处的其他用户建议它对电池消耗没有任何影响,并且文档指出位置管理器难以使用此标准节省电池:
但是,位置提供商使用minDistance参数更难以节省功耗,因此minTime应该是节省电池寿命的主要工具.
谷歌还建议使用重要的运动传感器来检测用户位置何时发生变化:
在高级别,重要的运动检测器用于降低位置确定的功耗.当定位算法检测到设备是静态的时,它们可以切换到低功率模式,在这种模式下,当用户改变位置时,它们依赖于显着的运动来唤醒设备.
这是否意味着位置管理器默认情况下使用重要的运动传感器,或者我是否需要激活或实施某些东西以使位置服务使用它?
加速度计怎么样?我的问题的很大一部分在于使用加速度计来检测用户何时开始移动会节省任何功率,因为使用加速度计将是另一个需要电源和回调处理的传感器.一些加速计传感器被谷歌列为低功率,而有些则不是(包括重要的运动传感器).
是否可以通过将GPS置于睡眠状态来节省任何电池电量,然后使用传感器检测用户移动,这将再次唤醒GPS?
我正在尝试在android中实现交互动画,用户可以在其中更改对象的大小并通过交互旋转它.
这不是我想要实现的,但类似的东西.
我想让用户改变角度线'p',并且角度'a'应该改变.移动'p'wrt中心应该允许形状的大小改变.
我已经尝试了动画和动画师类,但它们并没有完全达到目的.
我不是要求任何代码,我只需要一个指针就可以实现.
有人可以解释如何从android force close中了解logcat.
当我在onPause()中调用finish()时发生此崩溃.
这是DDMS截图http://www.2ql.net/uploads/1245827534.png
谢谢.
我正在构建一个聊天室应用程序,每隔X秒轮询一次新事件.每次发生这种情况时,此代码都会使用新数据更新RoomAdapter(ArrayAdapter的自定义子类)并将其滚动到底部:
RoomAdapter adapter = (RoomAdapter) getListAdapter();
for (int i=0; i<newEvents.size(); i++)
adapter.add(newEvents.get(i));
getListView().setSelection(events.size()-1);
Run Code Online (Sandbox Code Playgroud)
这很好,除了如果用户向上滚动以浏览房间的历史记录,它将在轮询发生时将她跳到底部.我想要做的是,如果用户已经在列表的底部,那么在对新事件进行轮询之后,它就会停留在那里.如果用户有意向上滚动,我希望用户不要被打扰.
如何检测我何时已滚动到ListView的底部?
注意:我不能做getListView().getSelectedItemPosition(),因为正如文档所说,在触摸模式下调用setSelection实际上并没有选择项目,只是滚动到它.
这个 XML 是从我的主要活动中夸大的,我想知道如何将夸大的视图设置为全屏或 fill_parent,如 XML 中所示,因为当我测试我的应用程序时,它会给我一个半尺寸的屏幕显示在右边。
第一张图片来自我的电脑,第二张图片来自我的标签。
这是我的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal|center_vertical"
android:background="@drawable/splash"
android:paddingBottom="@dimen/_16sdp"
android:paddingLeft="@dimen/_16sdp"
android:paddingRight="@dimen/_16sdp"
android:paddingTop="@dimen/_16sdp" >
<Button
android:id="@+id/g1btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/g1tv2"
android:layout_centerHorizontal="true"
android:text="BUTTON"
android:textSize="@dimen/_70sdp" />
<TextView
android:id="@+id/g1tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""THIS""
android:textSize="@dimen/_70sdp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/g1tv2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="66dp"
android:text="TAP"
android:textSize="@dimen/_70sdp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="GAME 1"
android:textSize="@dimen/_50sdp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的 MainActivity.Java
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method …Run Code Online (Sandbox Code Playgroud) 我的应用程序消耗了大量内存我使用以下应用程序来衡量我的应用程序内存消耗
https://play.google.com/store/apps/details?id=mem.usage&hl=en
任何人都可以告诉我如何优化我的应用程序使用的内存?
我正在使用Android Studio 1.5如何更新到android studio 2.0的测试版,当我试图更新其显示" 你已经安装了最新版本的Android Studio "时.
我想更新我的Android Studio,但我不知道如何做到这一点.
android ×12
listview ×2
android-wifi ×1
animation ×1
bluetooth ×1
ddms ×1
geolocation ×1
gps ×1
interaction ×1
java ×1
location ×1
maven ×1
mockito ×1
performance ×1
phone-call ×1