我看到了这个主题,并按照描述实现了IntentService,但如果我想要更多的那个按钮呢?如何区分按钮?我正在尝试setFlags,但无法在onHandleIntent()方法中读取它:
public static class UpdateService extends IntentService {
...
@Override
public void onHandleIntent(Intent intent) {
ComponentName me = new ComponentName(this, ExampleProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(me, buildUpdate(this));
}
private RemoteViews buildUpdate(Context context) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.main_layout);
Intent i = new Intent(this, ExampleProvider.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
updateViews.setOnClickPendingIntent(R.id.button_refresh, pi);
i = new Intent(this, ExampleProvider.class);
pi = PendingIntent.getBroadcast(context, 0, i, 0);
updateViews.setOnClickPendingIntent(R.id.button_about, pi);
return updateViews;
}
}
Run Code Online (Sandbox Code Playgroud)
在这一小段代码中我有两个与setOnClickPendingIntent链接的PendingIntent,我可以区分这个意图以进行不同的操作和处理吗?感谢帮助
我在app上有自定义注释引脚:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
return [kml viewForAnnotation:annotation type:state];
}
Run Code Online (Sandbox Code Playgroud)
我返回自定义视图并为Placemark的annotationView创建setImage,例如:
- (MKAnnotationView *)viewForAnnotation:(id <MKAnnotation>)point type:(int)state
{
// Find the KMLPlacemark object that owns this point and get
// the view from it.
for (KMLPlacemark *placemark in _placemarks) {
if ([placemark point] == point)
{
UIButton *disclosureButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
[[placemark annotationView] setCanShowCallout: YES];
[[placemark annotationView] setRightCalloutAccessoryView:disclosureButton];
if (state == 0)
{
[[placemark annotationView] setImage:[UIImage imageNamed:@"ic_pin_tour.png"]];
}
else
{
[[placemark annotationView] setImage:[UIImage imageNamed:@"ic_pin_point.png"]];
}
return [placemark …Run Code Online (Sandbox Code Playgroud) 尝试在我的iMac(2.4Ghz,4Gb RAM)上使用Eclipse for Android(ADT插件)开发,它非常慢(Eclipse Galileo SR2 x64).
我知道eclipse.ini技巧并做一些改变,如:
-XX:MaxPermSize参数=256米
-Xms256m
-Xmx1024m
-XX:+ UseCompressedOops
-XX:+ AggressiveOpts
-XX:+ UseConcMarkSweepGC
并默认使用Java 1.6:
-Dosgi.requiredJavaVersion = 1.6
但在小项目中仍然有冷冻.即使用50LOC滚动课程也很慢.在同一个项目中,IntellijIdea工作得更快.
有一些秘密法术可以赢吗?