我把我的Android项目移到了一台笔记本电脑上,现在我点击了Debug.听起来这是一个错误?据我所知,这不应该通过Eclipse发生.
Re-installation failed due to different application signatures.
Run Code Online (Sandbox Code Playgroud)
最奇怪的是,这是在我升级sdk/adt和Eclipse以支持SDK 2.2之后发生的.它之前工作正常,现在它没有,所以它可能是一个bug.
几天前,我一直在努力寻找一种方法来为警报使用自定义意图.虽然我得到了明确的答案,我必须根据一些独特的ID来定制Intents,例如.setAction()
还是有一些问题.
我用这种方式定义了PendingIntent:
Intent intent = new Intent(this, viewContactQuick.class);
intent.setAction("newmessage"+objContact.getId());//unique per contact
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK ).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
intent.putExtra("id", Long.parseLong(objContact.getId()));
intent.putExtra("results", result.toArray());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
Run Code Online (Sandbox Code Playgroud)
然后由通知管理器使用
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
// first try to clear any active notification with this contact ID
mNotificationManager.cancel(Integer.parseInt(objContact.getId()));
// then raise a new notification for this contact ID
mNotificationManager.notify(Integer.parseInt(objContact.getId()), notification);
Run Code Online (Sandbox Code Playgroud)
这样工作如下:
问题
对于联系人,这可能会发生多次.并且当生成第二条消息时,通知会很好地提出(消息在那里很好)但是当用户操作它使用旧数据的通知时的意图,所以先前的消息被传递而不是全新的消息.
所以,某种意图是缓存和重用以前的额外内容.如何使每个联系人和每个操作都具有唯一性?
问题很简单:
我有两个List
List<String> columnsOld = DBUtils.GetColumns(db, TableName);
List<String> columnsNew = DBUtils.GetColumns(db, TableName);
Run Code Online (Sandbox Code Playgroud)
我需要得到这些的交集.有没有快速实现这一目标的方法?
采取这种方法
/**
* @return List of group IDs the person belongs to
*
*/
public List<String> getGroups() {
if (this.getId().equals("")) return null;
}
Run Code Online (Sandbox Code Playgroud)
我想抛出异常而不是返回null,当没有设置重要的参数/依赖项时抛出的异常是什么?
我知道add()
根据日历的规则将指定(签名)的时间量添加到给定的时间字段.
并roll()
在给定时间字段上添加指定(签名)的单个时间单位,而不更改更大的字段.
我想不出日常使用roll()
我会做的一切add()
.
你能在什么时候使用roll()
以及什么时候使用例子来帮助我add()
?
编辑1
Joda答案不被接受!
我来自c#,这很容易,而且可能.
我有这个代码:
public abstract class clsAbstractTable {
public abstract String TAG;
public abstract void init();
}
Run Code Online (Sandbox Code Playgroud)
但是Eclipse告诉我我使用非法修改器.
我有这门课:
public class clsContactGroups extends clsAbstractTable {
}
Run Code Online (Sandbox Code Playgroud)
我希望以这种方式定义变量和方法,Eclipse 提示我,我没有实现抽象变量和方法.
我如何定义我的抽象类,以便提示我实现摘要?
编辑1
我将为不同的db表创建不同的类.每个类都应该有自己的TABLENAME变量,没有例外.每当我创建一个扩展抽象类的新类时,我必须确保这个变量是静态的.
然后在抽象类中我将有一个方法例如:init();
如果在这个init()方法中我调用TABLENAME,它应该从子类中获取值.
这样的事情也应该成功
String tablename=(clsAbstract)objItem.TABLENAME;
// where objItem can be any class that extended clsAbstract;
Run Code Online (Sandbox Code Playgroud)
编辑2
我希望在每个类中定义一个常量(静态),其名称用abstract定义.
我正在使用以下代码将备份副本写入SDCard,我得到了
java.io.IOException: Parent directory of file is not writable: /sdcard/mydbfile.db
private class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {
private final ProgressDialog dialog = new ProgressDialog(ctx);
// can use UI thread here
protected void onPreExecute() {
this.dialog.setMessage("Exporting database...");
this.dialog.show();
}
// automatically done on worker thread (separate from UI thread)
protected Boolean doInBackground(final String... args) {
File dbFile =
new File(Environment.getDataDirectory() + "/data/com.mypkg/databases/mydbfile.db");
File exportDir = new File(Environment.getExternalStorageDirectory(), "");
if (!exportDir.exists()) {
exportDir.mkdirs();
}
File file = new File(exportDir, dbFile.getName());
try …
Run Code Online (Sandbox Code Playgroud) 通过在Eclipse中点击Debug启动模拟器后,在一定时间后它与ADB断开连接,但模拟器保持打开状态.它响应迅速,我可以导航和启动应用程序.
如何将仿真器附加到ADB,以便能够从Eclipse进行调试?
(当前的解决方法是终止模拟器,关闭Eclipse并重新启动它们,这需要10分钟,因为您知道模拟器需要时间来启动)
编辑1
看看这个图像:
编辑2
我杀了并重新启动服务器后.一个模拟器进程显示在Eclipse的Devices选项卡中.但这不能扩展,我也看不到子流程.
我已经无法调试了,因为它说:Debug已经运行了.(如何停止调试?)
如果我设法启动另一个项目的调试,它会在模拟器中挂起,告诉我:等待调试器附加.什么都没发生.
我有这个代码来显示带有单选(无线电)选项的对话框.
AlertDialog ad = new AlertDialog.Builder(this)
.setCancelable(false)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(R.string.choose_one)
.setSingleChoiceItems(seq, pos,null)
.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int whichButton)
{
// dialog dismissed
}
}).create();
Run Code Online (Sandbox Code Playgroud)
我如何获得所选的选择?
如何测试以下所有方法代码?我想在所有这些场景发生时播放场景,看看我的代码是否适用于活动的保存/恢复过程.那么我应该在模拟器中做些什么来测试所有方法呢?
public class Activity extends ApplicationContext {
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestoreInstanceState(Bundle savedInstanceState);
protected void onSaveInstanceState(Bundle savedInstanceState);
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}
Run Code Online (Sandbox Code Playgroud)