我需要在我的应用程序中添加一个警报系统.当读取一些数据时,我需要提醒用户数据.我需要一个对话框弹出让用户知道它发生的时间并告诉他们其他一些东西.用户需要单击确定即可.只是为了引起他们的注意.我需要它来制造噪音和振动.我正在调查通知和alertdialogs.AlertDialog似乎是我想要的,但是,我在alertdialog的文档中没有看到任何关于声音和振动的信息.alertdialog有噪音和振动吗?还是有另一种方式让我用声音和振动做到这一点?我需要窗口保持活动状态,直到用户按下确定.
谢谢!
我有一个应用程序需要能够使用身份验证请求发送到https,然后是注册请求.目前我能够将我的身份验证请求发布到https,它工作正常.当我尝试将我的注册请求发布到https时,我不断收到服务器响应,说我需要进行身份验证.在我尝试注册之前,我正在验证.
服务器的管理员说我可能没有保留会话.我是新手用android和java做的东西.我是这个https的新手.我想知道是否有人可以在这里帮助我,我不知道这是肯定的问题,甚至不知道如何在android中保留https会话.
以下是我的代码,非常感谢任何建议!!!! 提前致谢!!
//my helper class
public class SmartDBHelper {
private static Context tThis;
private static SmartDBHelper sDBHObject;
private static String macAddress;
private static String ipAddress;
private static HttpsURLConnection https;
/* constructor, private prevents any other class from instantiating */
private SmartDBHelper() {
}
public static synchronized SmartDBHelper getSDBHObject() {
if(sDBHObject == null) {
sDBHObject = new SmartDBHelper();
}
return sDBHObject;
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
public static synchronized void setSmartContext(SmartApp smartApp) …Run Code Online (Sandbox Code Playgroud) 我的屏幕上有10*3个按钮.当我点击一个按钮时,我希望它不可见,所以我这样做:
arg0.setVisibility(View.GONE);
但是当按钮消失时,按钮会改变它们的大小.例如,如果在开始时每个按钮占用1/3行,现在当按钮消失时,行中的其他按钮变宽.
有没有办法让他们在删除按钮时不改变尺寸?
该应用程序拦截短信息并显示一条Dialog消息.
但是我无法Dialog在Test课堂上解决我的错误.我究竟做错了什么?
(我还包括了我的其他2个文件).
Eclipse中显示的错误: AlertDialog.Builder(Test) is undefined
test.java
package com.example.firstapp;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
public class Test extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for …Run Code Online (Sandbox Code Playgroud) 我正在研究一种使用Min3d/Rajawali框架围绕3D物体旋转相机的算法.
在我的实现中,绕X轴的旋转不能正常工作.我认为该方法setLookAt()无法正常工作.
问题:
当我垂直旋转球体时,我无法完全看到它.例如,转动地球,我无法完全看到南极,因为算法会重置相机.
是否可以在不使用"setLookAt"方法的情况下实现相机围绕物体旋转?
我尝试了不同的解决方案,但无法使其正常工作.
以下是我的代码:
initScene:
scene.camera().position.z = 90;
scene.camera().target = raketeOBJ.position();
onTouchEvent:
public boolean onTouchEvent(MotionEvent me) {
if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}
if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}
if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;
xpos = me.getX();
ypos = me.getY();
touchTurn …Run Code Online (Sandbox Code Playgroud) 我有一个以TextView3 Buttons为中心的a RelativeLayout和3,其中所有三个中的文本左对齐,父中心为最左边的行.
我试着改变gravity了的TextView,Buttons和布局,但没有什么工作,我百思不得其解,因为我从来没有见过的Android对齐文本是这样了.
我希望Button文本在每个文本中居中Button,顶部文本在中心对齐.
它的外观图像如下:http://i.stack.imgur.com/9lHEd.png
这是我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:gravity="center_horizontal"
android:text="@string/greeting"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/startQuizButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:onClick="@string/startQuiz"
android:text="@string/start_quiz" />
<Button
android:id="@+id/lessonsButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/startQuizButton"
android:layout_centerHorizontal="true"
android:onClick="@string/startLesson"
android:text="@string/lessonsString" />
<Button
android:id="@+id/viewAllButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/lessonsButton"
android:layout_centerHorizontal="true"
android:onClick="@string/showAll"
android:text="@string/view_all" />
Run Code Online (Sandbox Code Playgroud)
下面的代码段else应该进入语句elif.
#The following line returns 3, 4 or 5 as the exit code.
$BASH_EXEC adbE.sh "adb $ARGUMENT install $f"
echo "the return code:$?."
if [ $? -eq 5 ]
then
#do nothing, success
continue
elif [ $? -eq 4 ]
then
echo "WARNING"
else
echo "ERROR"
break
fi
Run Code Online (Sandbox Code Playgroud)
这部分:echo "the return code:$?."将此回显到屏幕:the return code:4.
并且它不显示WARNING.它只显示ERROR然后打破for包含此代码的循环.
我究竟做错了什么?
以下是我尝试过的条件比较的变化导致了同样的问题:
if [ $? -eq 5 ]if [ $? -eq …使用gradle与android.
我试图powermock编译为依赖.
我已经愚弄了我的尝试,让它工作,它仍然无法正常工作.下面是我的build.gradle和activity.我只是这样做来演示错误并试图让它工作.
//Error
error: package org.powermock.api.easymock does not exist
import org.powermock.api.easymock.PowerMock;
Run Code Online (Sandbox Code Playgroud)
//build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "android.testing.powermock"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'org.easymock:easymock:3.3.1'
compile 'org.powermock:powermock-easymock-release-full:1.6.2'
}
Run Code Online (Sandbox Code Playgroud)
//MainActivity
package android.testing.powermock;
import org.powermock.api.easymock.PowerMock;
public class MainActivity extends Activity {
//not important
}
Run Code Online (Sandbox Code Playgroud) 有谁知道如何创建一个按钮,可以帮助我在标签之间切换?
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {{
// Perform action on click
if (v.getId() == R.id.button1) {
setContentView(R.layout.tab3);
}
else if (v.getId() == R.id.button1) {
setContentView(R.layout.main);
}
}
}
});
}}
Run Code Online (Sandbox Code Playgroud)
这是我的选项卡1中的代码,下一个代码是我的tab.xml中的按钮.我想按下面的购买按钮,我希望它转到另一个标签,这可能吗?
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/imageButton1"
android:text="Buy"
android:onClick="tab3" />
Run Code Online (Sandbox Code Playgroud)
这是我的logcat文件
01-05 16:04:20.903: D/dalvikvm(215): GC freed 806 objects / 70928 bytes in 96ms
01-05 15:30:29.072: D/AndroidRuntime(213): Shutting down VM
01-05 15:30:29.082: W/dalvikvm(213): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-05 15:30:29.082: E/AndroidRuntime(213): …Run Code Online (Sandbox Code Playgroud)