我想以编程方式更改系统亮度.为此我使用此代码:
WindowManager.LayoutParams lp = window.getAttributes();
lp.screenBrightness = (255);
window.setAttributes(lp);
Run Code Online (Sandbox Code Playgroud)
因为我听说最大值是255.
但它什么都没做.请建议任何可以改变亮度的东西.谢谢
我正在开发一个应用程序,我想sqlite
从项目的资产文件夹中读取数据库文件.我搜索过网络但没有找到任何帮助.请帮我.谢谢.
谁能告诉我如何将自定义Serializable
对象列表保存 到SharedPreference
?我是Android新手,我希望将其保存ArrayList<Contact> list
到共享首选项中.
public class MainActivity extends SherlockFragmentActivity {
PlaceSlidesFragmentAdapter mAdapter;
ViewPager mPager;
PageIndicator mIndicator;
public static final String TAG = "detailsFragment";
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.main,
container, false);
mAdapter = new PlaceSlidesFragmentAdapter(getActivity()
.getSupportFragmentManager());
mPager = (ViewPager) view.findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mIndicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
((CirclePageIndicator) mIndicator).setSnap(true);
mIndicator
.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
Toast.makeText(MainActivity.this.getActivity(),
"Changed to page " + position,
Toast.LENGTH_SHORT).show();
}
@Override …
Run Code Online (Sandbox Code Playgroud) 我想知道Flat button
和之间的基本区别Raised Button
。根据新的Android
材料设计指南,我想使用凸起的按钮,但我不知道它们是什么。Web上有一些论坛显示了一个被升起的按钮,但他们称其为Flat。
谁能告诉我两者的基本区别?(具体来看)
嗨,我想将传入的数字记录到数据库.我正在使用广播接收器来收听电话和使用电话状态监听器.这是我的代码
ThePhoneStateListener.java
package com.example.netlogger.Receiver;
import android.content.Context;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
public class ThePhoneStateListener extends PhoneStateListener {
Context context;
public ThePhoneStateListener(Context context) {
this.context = context;
}
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
Log.d("TAGG", "Insert: " + incomingNumber);
}
}
}
Run Code Online (Sandbox Code Playgroud)
CallActionReceiver.java
package com.example.netlogger.Receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class CallActionsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) { …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想保存数据savedInstanceState()
.我想保存ArrayList<HashMap<String,String>>
.到目前为止,我无法做到这一点.这是我困扰我的代码
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelableArrayList("places", (ArrayList<? extends Parcelable>) places);
}
Run Code Online (Sandbox Code Playgroud)
restore()方法
private void restore(Bundle savedInstanceState) {
// TODO Auto-generated method stub
//What should i do here! i have try many things but none of them is helping
}
Run Code Online (Sandbox Code Playgroud) 嗨,我正在制作报警应用程序.当闹钟时间到来时我正在向用户显示一个对话框.但问题是我想在对话框出现时获取唤醒锁定.就像短信收到屏幕时醒来一样.
我试过这个但是没有用
public class Alarm extends Activity{
PowerManager pm;
WakeLock wl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pm = (PowerManager) getSystemService(POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "FlashActivity");
wl.acquire()
showAlarmDialog();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
wl.release();
}
}
Run Code Online (Sandbox Code Playgroud)
我也添加了wakelock权限.帮助将是appriciated :-)
我有这个令人毛骨悚然的问题.我想要获得我的模拟器的位置.当我得到我的模拟器的位置时它工作正常.但是当我改变我的位置坐标时没有任何反应.gps
工作正常.
这是我的代码
Main.java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
public class Main extends Activity {
TextView tvStatus;
LocationManager lm;
boolean gpsEnabled;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvStatus = (TextView) findViewById(R.id.textView1);
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.d("", "GPS is Active");
Location l = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
tvStatus.setText(l.getLatitude()+" , "+l.getLongitude());
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
new LocationListener() {
@Override …
Run Code Online (Sandbox Code Playgroud) 我想将音频文件存储在mysql
数据库中.我LONGBLOB
用来存储base64
这个音频文件的编码字符串.但正如我执行我的查询,我收到此警告,没有插入数据库:
Warning: mysql_query() [function.mysql-query]: MySQL server has gone away
Run Code Online (Sandbox Code Playgroud)
当我上传任何图像文件,我没有得到任何错误,代码工作正常.当我上传视频和音频文件时会发生这种情况.在我正在使用的代码中:
<?php
include 'database_handler.php';
if(isset($_FILES['fileToUpload']['name'])){
echo "uploading. . .";
$file = rand(0, 10000000).$_FILES['fileToUpload']['name'];
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file)) {
if($fp = fopen($file,"rb", 0))
{
$picture = fread($fp,filesize($file));
fclose($fp);
$base64 = base64_encode($picture);
//echo $base64;
$db = new Database();
$db->test($base64);
}
}
}
?>
<form action="test.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
这是我正在调用的函数代码:
function test($base64String){
if (mysql_query("update users set …
Run Code Online (Sandbox Code Playgroud) 我是新来的osmdroid
。我正在使用离线地图mbtiles
。我在地图上使用了太多标记,这使得我的地图非常慢。我读到了一些聚类会有所帮助的地方,但我没有得到任何关于如何在osmdroid
. 请帮忙。