我正在尝试使用两种不同的方法创建和删除警报,这两种方法都在应用程序逻辑的不同时刻调用.
但是,当我调用AlarmManager的cancel()方法时,不会删除警报.
这是我的addAlarm()方法:
AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra("ALERT_TIME", alert.date);
intent.putExtra("ID_ALERT", alert.idAlert);
intent.putExtra("TITLE", alert.title);
intent.putExtra("GEO_LOC", alert.isGeoLoc);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
alert.idAlert, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar calendar = Calendar.getInstance();
calendar.setTime(alert.date);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
Log.e("ADD ALERT - WithoutGeoLoc - ",alert.toString());
Run Code Online (Sandbox Code Playgroud)
这是我的deleteAlarm()方法:
AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra("ALERT_TIME", alert.date);
intent.putExtra("ID_ALERT", alert.idAlert);
intent.putExtra("TITLE", alert.title);
intent.putExtra("GEO_LOC", alert.isGeoLoc);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
alert.idAlert, intent, PendingIntent.FLAG_CANCEL_CURRENT);
alarmManager.cancel(pendingIntent);
Log.e(TAG,"REMOVE ALERT - without GeoLoc"+alert.toString());
Run Code Online (Sandbox Code Playgroud)
这是我的Logcat:
01-23 …Run Code Online (Sandbox Code Playgroud) 我已经设法实现了一个很棒的列表视图,我在这里找到了http://www.learn-android.com/2011/11/22/lots-of-lists-custom-adapter/comment-page-1/ 但我可以似乎添加了一个onclicklistener我只是希望能够在我点击该行时执行操作,该行包含的数据当然有任何想法吗?谢谢
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.liste);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// Setup the list view
final ListView prestListView = (ListView) findViewById(R.id.list);
final prestationAdapterEco prestationAdapterEco = new prestationAdapterEco(this, R.layout.prestation);
prestListView.setAdapter(prestationAdapterEco);
// Populate the list, through the adapter
for(final prestationEco entry : getPrestations()) {
prestationAdapterEco.add(entry);
}
prestListView.setClickable(true);
prestListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Object o = prestListView.getItemAtPosition(position);
String str=(String)o;//As you are using Default String Adapter
Toast.makeText(getApplicationContext(),str,Toast.LENGTH_SHORT).show();
}
});
}
Run Code Online (Sandbox Code Playgroud) 我正试图从我的Android手机上获取我的传感器的倾斜角度,滚动角度,但到目前为止没有成功,
当我点击我应该给我3个角度的按钮时,我得到"结果:0.0 -0.0 -0.0"
package com.example;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Button;
import android.view.View;
public class MyActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final float[] mValuesMagnet = new float[3];
final float[] mValuesAccel = new float[3];
final float[] mValuesOrientation = new float[3];
final float[] mRotationMatrix = new float[9];
final Button btn_valider = (Button) findViewById(R.id.btn1);
final TextView txt1 …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个看起来像这样的好日期选择器

而不是

要么

有任何想法吗?
我正在使用这个CoverFlow:http: //www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html
我希望能够在单击按钮时更改View,该按钮是后退/前进图标,可以将您带到封面流中的上一个/下一个项目.
我稍微修改了封面流程,以便我使用XML布局.
这是我的onCreate()方法:
setContentView(R.layout.main);
CoverFlow coverFlow = (CoverFlow)findViewById(R.id.coverflow);
coverFlow.setAdapter(new ImageAdapter(this));
ImageAdapter coverImageAdapter = new ImageAdapter(this);
coverFlow.setAdapter(coverImageAdapter);
coverFlow.setSpacing(-20);
coverFlow.setSelection(0, true);
coverFlow.setAnimationDuration(1000);
tv = (TextView)findViewById(R.id.textView1);
coverFlow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getBaseContext(), String.valueOf(arg2), Toast.LENGTH_SHORT).show();
}
});
coverFlow.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
tv.setText(String.valueOf(arg2));
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// Do something
}
});
Run Code Online (Sandbox Code Playgroud)
我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout …Run Code Online (Sandbox Code Playgroud) 我正在使用android注释,我正在尝试注释这个类,以便我可以使用@pref将值保存到我的共享首选项(带注释)类中.我已经设法找到了一个有意图和广播接收器的工作但是这不是理想的,现在我想从这个类中的共享首选项中获取一个值,以显示在微调器中选择的默认项目它开始给我的代码留下气味.
有没有办法注释这个类?
public class SelectNewsFeedDialog extends Dialog {
private Context context;
private Button confirmButton;
private Spinner spinnerTeams;
public SelectNewsFeedDialog(final Context context, ArrayList<Team> listTeams) {
super(context,R.style.cust_dialog);
this.context = context;
setContentView(R.layout.dialog_choose_news_feed);
spinnerTeams = (Spinner) findViewById(R.id.dialog_news_feed_spinner_teams);
confirmButton = (Button) findViewById(R.id.dialog_news_feed_button_confirm);
confirmButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Team team = (Team)spinnerTeams.getSelectedItem();
Intent intent = new Intent(context, IntentCenter_.class);
intent.putExtra(context.getString(R.string.extra_update_team_news_feed), team.url.toString());
intent.setAction(context.getString(R.string.action_update_team_news_feed));
context.sendBroadcast(intent);
dismiss();
}
});
SpinnerTeamsAdapter adapter = new SpinnerTeamsAdapter(context, listTeams);
spinnerTeams.setAdapter(adapter);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用cordova/phonegap制作一个Windows手机应用程序,我正试图在事件发生时从C#调用脚本.
反正有没有这样做?
这是我到目前为止的课程.
public void register(string options)
{
// This is executed asynchronously
if (!TryFindChannel())
DoConnect();
}
void httpChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
{
// Finished asynchronous task in "register" method
Trace("Channel opened. Got Uri:\n" + httpChannel.ChannelUri.ToString());
SaveChannelInfo();
Trace("Subscribing to channel events");
SubscribeToService();
SubscribeToNotifications();
// SEND CHANNEL URI TO JAVASCRIPT
}
Run Code Online (Sandbox Code Playgroud) 几乎不言自明.
我有一个字符串:
8:4,7:2,...
Run Code Online (Sandbox Code Playgroud)
我需要从中获取值,字符串的长度未定义,它只有这种格式:
id:quantity,id:quantity,...
Run Code Online (Sandbox Code Playgroud)