我想将16位pcm音频下采样到8位,然后在android中将8位上采样到16位.我正在使用这似乎工作:
int tempint;
for (int i=1, j=0; i<tempBuffer.length; i+=2, j++)
{
tempint = ((int) tempBuffer[i]) ^ 0x00000080;
tempBuffer[j] = (byte) tempint;
Log.e("test","------------* COUNTER -> "+j+" BUFFER VALUE -> "+tempBuffer[j]+"*-----------");
}
Run Code Online (Sandbox Code Playgroud)
其中tempbuffer是short [],tempint是int.任何人都可以告诉我,如果这是正常的,因为我是一个启动器,我也使用它将字节[]转换回短[]
for (int x=1, j=0; x<music.length; x+=2, j++)
{
tempint = ((int) music[x])& 0xFF;
music[j] = tempint.shortValue();
Log.e("maxsap","------------*"+ music[j]+"*-----------");
}
Run Code Online (Sandbox Code Playgroud)
我不确定它是否有效.
我有以下代码:
if (gps_enabled) {
Log.e("$$$$$$$$$$$$$$",
"GPS is enabled requestion location updates... interval value is: "
+ interval);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locationListenerGps);
}
else{
if (network_enabled) {
Log.e("$$$$$$$$$$$$$$",
"Network is enabled requestion location updates... interval value is: "
+ interval);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,
0, locationListenerNetwork);
}
}
Run Code Online (Sandbox Code Playgroud)
使用该代码,我可以获得位置(至少使用网络提供商!(另一个帖子上的另一个问题))我希望每隔一小时定期收到通知,但是将参数传递给requestLocationUpdates并不保证将保持间隔(至少我的测试显示,因为我期望每分钟更新,但得到了很多更新,而不是一个!)所以我想使用timerTask并安排它,我现在有
timer1.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
getLocation();
}
}, 0, 180000);// 3 minutesr...
Run Code Online (Sandbox Code Playgroud)
其中getLocation是我之前调用的方法,但是当定时器调用该方法然后没有任何反应时,日志就此停止了
Log.e("$$$$$$$$$$$$$$",
"Network is enabled requestion location updates... interval value is: "
+ interval);
Run Code Online (Sandbox Code Playgroud)
我从来没有得到有关我的位置的通知.有任何想法吗?
您好我正在构建一个应用程序,它将在固定的时间段(例如每30分钟)执行一段代码.我希望那个时期是严格的,我的意思是我希望保证这段时间是30分钟而不是28分钟,或者只要操作系统执行它.
我有一个Timer对象,并按如下方式使用它:
timer=new Timer();
timer.scheduleAtFixedRate(new GetLastLocation(), 0, this.getInterval());
其中GetLastLocation是扩展TimerTask的处理程序类.这工作正常,但我希望能够更改间隔,我目前正在做的是使用timer.scheduleAtFixedRate两次并更改interval参数让我们说一个newInterval但我认为这只是有两个定时器执行每个间隔现在,新的Interval,我是对的吗?
我也尝试取消定时器,然后使用方法scheduleAtFixedRate(),但这会引发文档中所述的异常.
我该怎么做才能解决这个问题?关于maxsap
我正在浏览网页,我看到一个声称要扫描用户指纹的应用程序,所以我想我应该尝试一下,应用程序运行良好,我很惊讶!有谁知道这个应用程序如何读取用户的指纹?这怎么可能在Android上?任何教程或提示或任何开源项目?我认为这将有助于很多开发人员.
您好我想使用delphi 7编程语言开发但我有一些问题,
首先是有很多不同的delphi语言,例如Borland Delphi,Delphi 7等?
第二,是否有任何官方网站提供有关Delphi的资源?
我想使用borland delphi 7工作室,但我在www.borland.com网站上找不到它,它是商业IDE吗?
您好我正在尝试使用此代码从服务启动Android浏览器:
protected void showBrowser(){
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
this.startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用!浏览器永远不会启动,并且使用日志会在调用startActivity时停止执行.
您好我有一个ListFragment从网络中获取一些数据,然后使用渲染器显示它们.问题是,如果我添加一个简单的TextView,如下所示:
TextView tv = new TextView(getActivity());
然后它工作正常,但如果我尝试添加更复杂的视图,那么应用程序会冻结.我也试图从xml中膨胀视图,但没有运气.基本上我试图给这个RelativeLayout充气:
<RelativeLayout
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:background="@color/main_background" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/leave_comment"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="@color/resultlist_title"/>
<EditText
android:id="@+id/editText1"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginLeft="10dp"
android:inputType="textPostalAddress" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/leave_commentbtn"
android:background="@drawable/venue_post"
android:layout_below="@+id/textView1"
android:layout_toRightOf="@+id/editText1"
style="@style/list_button"
android:layout_marginLeft="18dp"
android:layout_centerInParent="true"
android:textColor="@color/white"/>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?是否无法将相对布局添加为页脚视图?
这是场景:
所以问题是我应该使用服务进行通信以及提供什么类型的服务?
我是否应该在服务中使用AsyncTask以保持我的UI响应以及为什么?