在我的应用程序中,我正在尝试使用警报管理器启动服务.当我点击按钮时,服务应该在我给出的特定时间开始.我的警报管理器代码如下:
public void onClick(View view)
{
if(view == m_btnActivate)
{
Calendar cur_cal = Calendar.getInstance();
cur_cal.setTimeInMillis(System.currentTimeMillis());
cur_cal.add(Calendar.SECOND, 50);
Log.d("Testing", "Calender Set time:"+cur_cal.getTime());
Intent intent = new Intent(DashboardScreen.this, ServiceClass.class);
Log.d("Testing", "Intent created");
PendingIntent pi = PendingIntent.getService(DashboardScreen.this, 0, intent, 0);
AlarmManager alarm_manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm_manager.set(AlarmManager.RTC, cur_cal.getTimeInMillis(), pi);
Log.d("Testing", "alarm manager set");
Toast.makeText(this, "ServiceClass.onCreate()", Toast.LENGTH_LONG).show();
}
}
Run Code Online (Sandbox Code Playgroud)
而bellow是我的服务类:
public class ServiceClass extends Service{
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Log.d("Testing", "Service got created");
Toast.makeText(this, "ServiceClass.onCreate()", Toast.LENGTH_LONG).show();
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用缩略图来处理ListView中的图像文件的AsyncTask.我一直遇到行回收的常见问题,因此滚动缩略图被分配给错误的行.我已经尝试将标签添加到ImageView,然后在AsyncTask中的onPostExecute()中确认标签,但是在我的尝试中却没有成功.有人请帮忙!
自定义适配器如下:
public class MySimpleAdapter extends SimpleAdapter {
public MySimpleAdapter(Context context,
List<? extends Map<String, ?>> data, int resource,
String[] from, int[] to) {
super(context, data, resource, from, to);
// TODO Auto-generated constructor stub
}
public View getView(int position, View convertView, ViewGroup parent) {
final View v = super.getView(position, convertView, parent);
thumbnail = (ImageView) v.findViewById(R.id.thumbnail);
checker = (CheckBox) v.findViewById(R.id.checkBox);
filenametext = (TextView) v.findViewById(R.id.text1);
String pathtoimage = startLocation.concat("/"
+ filenametext.getText().toString());
desctext = (TextView) v.findViewById(R.id.text2);
String temp = desctext.getText().toString();
if (temp.equals("Directory") == true) …Run Code Online (Sandbox Code Playgroud) 是否有任何Sencha Touch 2 IDE或编辑器?我知道Sencha Architect 2.但它太贵了.如果有人使用Sencha Touch IDE,那么我们只能给出CTRL + SPACE,它会给我所有的方法吗?
我想在Android中使用文本作为按钮.假设我有一个像'Register'这样的文本.我想使用此文本作为按钮意味着当我点击文本时,它将打开注册屏幕.我正在使用XML来开发UI,我正在为Android平板电脑应用程序做这件事.
提前致谢
我有一个Action Bar,我想使用Menu添加一个帮助按钮.我使用的是Android 3.0.我的菜单代码如下:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/help_btn"
android:icon="@drawable/help"
android:title="Help"
android:showAsAction="ifRoom|withText"
/>
Run Code Online (Sandbox Code Playgroud)
现在我如何在操作栏中添加此菜单?
Eclipse没有认识到google nexus one设备.但是安装了Usb驱动程序.因为在Android SDK Manager中,它表示安装了Google USB驱动程序包.那么为什么它不能识别?我使用的是Windows XP平台.
任何人都可以帮助我.
我正在开发一个应用程序,我想播放直播电台.我有一个网址用于流媒体和播放.我有一个播放按钮,点击我要播放收音机.为此,我写了一些根本没有工作的代码.这是我的代码:
mp = new MediaPlayer();
try {
mp.setOnPreparedListener(this);
Log.d("Testing", "start111");
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
String url="xxxxxx";
mp.setDataSource(url);
mp.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
Log.d("Testing", "Exception ::: 1111 "+e.getMessage());
} catch (IllegalStateException e) {
Log.d("Testing", "Exception ::: 2222 "+e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.d("Testing", "IOException ::: 3333 "+e.getMessage());
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
谁能帮帮我吗??
我正在尝试使用WorkManager进行服务器调用。所以,我写了下面的Worker类:
class ServerCallWorker extends Worker {
public ServerCallWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
Log.d("Testing", "ServerCallWorker constructor method" );
}
@NonNull
@Override
public Worker.Result doWork() {
Log.d("Testing", "doWork() method" );
return Worker.Result.SUCCESS;
}
}Run Code Online (Sandbox Code Playgroud)
我正在从活动的onCreate()方法调用此工作者类。代码段在这里:
private void getLocationUpdate() {
Log.d("Testing", "inside Location Update");
WorkManager workManager = WorkManager.getInstance();
Log.d("Testing", "inside Location Update 222");
Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType
.CONNECTED).build();
// PeriodicWorkRequest recurringWork = new PeriodicWorkRequest.Builder(FilterWorker.class, 15,
// TimeUnit.MINUTES).build();
OneTimeWorkRequest wrkReq = new OneTimeWorkRequest.Builder(ServerCallWorker.class).setConstraints(constraints)
.build();
Log.d("Testing", "inside Location Update 333"); …Run Code Online (Sandbox Code Playgroud)我在java中有一个程序.我对输出感到困惑.
public static void main(String args[])
{
int n=0;
for(int m=0; m<5;m++)
{
n=n++;
System.out.println(n);
}
}
Run Code Online (Sandbox Code Playgroud)
这里输出为0 0 0 0 0
但如果我写,
public static void main(String args[])
{
int n=0;
for(int m=0; m<5;m++)
{
n++;
System.out.println(n);
}
}
Run Code Online (Sandbox Code Playgroud)
然后输出是1 2 3 4 5
它为什么会这样来?
我使用 Apache HTTP Server mod_proxy 作为我的客户端和服务器之间的代理服务器。我能够从我的客户端连接到我的代理服务器。然后客户端能够建立连接并将数据发送到服务器。但在中间,某处连接丢失,并给出以下错误:
(OS 10054)An existing connection was forcibly closed by the remote host. : proxy: prefetch request body failed to 10.131.x.x:80 (10.131.x.x) from 10.131.y.y ()
Run Code Online (Sandbox Code Playgroud)
我曾尝试添加 keep alive 和其他属性,但它没有解决我的问题。这是我的 httpd.config 文件更改:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<IfModule mod_proxy.c>
ProxyRequests On
ProxyVia On
</IfModule>
<Proxy *>
Order deny,allow
Deny from all
Allow from 10.131.x.x
</Proxy>
Run Code Online (Sandbox Code Playgroud)
还添加了这个变量:
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 15
Listen 8080
Run Code Online (Sandbox Code Playgroud)
请需要知道是否有人遇到过同样的问题并解决了它。
谢谢,阿林达姆。
android ×7
apache ×1
httpd.conf ×1
httpserver ×1
java ×1
listview ×1
mod-proxy ×1
proxy ×1
radio ×1
recycle ×1
sencha-touch ×1
service ×1
thumbnails ×1