android周边游app的技术memo

周边游app的技术memo。

1 json接口定义

 时间尽量用timestamp。

2 支付接入

 支付用的支付宝快捷支付和WAP支付,因为后台问题,暂时是在客户端签名(快捷支付就没有通过后台)。

3 第三方接入

 基本用的友盟,包括第三方登录分享(微博、微信、朋友圈、QQ、腾讯微博,没有用SSO),用户反馈,自动更新,行为统计(自定义事件)。

 挺方便的,基本按照友盟的guide就行。就是要注意申请的对不对,比如用release签名申请的微信,这边还一直用debug签名在调,费劲好久才发现。

 消息推送用的Jpush,可以根据别名和标签推送。标签可以多个。

4 定位、地图、导航

 定位不能用android自带的api,有偏移。用百度的定位sdk,地图sdk,包括覆盖物、路径规划。

 有些开发版的手机定位不好,没定位到就会跑掉非洲边上的海里,可能那地方经纬度都是0。

 不爽的是移动版sdk没有setcenter("城市名")这样的接口来切换城市,只能用经纬度。网页版有。

5 网络

 没用afinal之类。就简单的用了HttpURLConnection。

 多线程发现AsyncTask不同版本上表现不一致, 2.3sdk上编译的在4.0以上运行竟然并发线程数为1,

 只好把AsyncTask源代码拷过来,改下线程数。没有其他依赖文件。

6 异常

 不知为何后期logcat中再不打印exception信息,就是tag为RuntimeError的那些。可能是某个第三方库引起的?

 只好实现了一个UncaughtExceptionHandler来输出,这样也好,还能把crash信息存到文件,甚至通过网络发送出来。

7 数据实体类entity

 开始所有entity实现的是Serializable接口,后来发现如果要在activity之间传送entity的list,必须实现Parcelable接口。

8 db

 开始说基本不存本地,就没加db,后来消息还是需要存,不想写db,就直接将对象list序列化到文件存在sd卡中算了。

 接口还是写成insertMessage、updateMessage、deleteMessage这样仿数据库的。

 还做了一点list排序(Collections.sort)和去重(TreeSet),就是重写两句java自带的Comparator。

9 utility

 getNetworkStatus、sdCardIsAvailable、enoughSpaceOnSdCard、enoughSpaceOnPhone、isValidMobile、readFile、saveFile、GetVersion、getImei

10 列表list的上拉分页、下拉刷新

 开始同事找的一个控件有手势冲突之类的问题,后来同事换了个PullToRefreshListView,还不错。

11 日期选择

 日期选择页面显示的是三四个月的价格,得手工在convas上绘制线条图形和文字,有点工作量,有经验也至少得好几天。

12 PopupWindow bug

 发现PopWindow在Android 2.3上运行的一个bug。不能直接(显式或隐式)调用其无参构造函数,得在子类构造函数中先调用super(context)。

 问题在android源码http://androidxref.com/2.3.7/xref/frameworks/base/core/java/android/widget/PopupWindow.java#setContentView,第384行。

 解决办法来自wangpingtaohn的博客:http://my.eoe.cn/545347/archive/19796.html。

抱歉,我无法提供完整的程序。但是,我可以提供一些基本的步骤和代码片段,以帮助你开始编写备忘录应用程序。 步骤: 1. 创建一个新的 Android Studio 项目。 2. 添加一个 RecyclerView 和一个 FloatingActionButton 来显示备忘录列表和添加备忘录按钮。 3. 创建一个备忘录数据模型类,包含标题、内容和日期等属性。 4. 创建一个备忘录适配器类,用于将备忘录数据绑定到 RecyclerView 上。 5. 创建一个数据库帮助类,用于创建和管理备忘录数据表。 6. 创建一个备忘录操作类,用于执行数据库操作,如添加、删除和更新备忘录。 7. 在 MainActivity 中初始化 RecyclerView、FloatingActionButton 和备忘录操作类。 8. 在 FloatingActionButton 的点击事件中启动一个新的 Activity,用于添加新的备忘录。 9. 在添加备忘录的 Activity 中,将用户输入的数据保存到数据库中。 10. 在 MainActivity 中,通过备忘录操作类查询数据库中的备忘录数据,并将其显示在 RecyclerView 上。 11. 在 RecyclerView 的每个备忘录项中,添加一个点击事件处理程序,以便用户可以查看和编辑备忘录。 12. 在查看和编辑备忘录的 Activity 中,将备忘录数据从数据库中加载并显示在相应的输入控件上。用户可以对备忘录进行编辑,然后将更改保存到数据库中。 代码片段: 备忘录数据模型类: ``` public class Memo { private long id; private String title; private String content; private String date; public Memo(long id, String title, String content, String date) { this.id = id; this.title = title; this.content = content; this.date = date; } // getters and setters } ``` 备忘录适配器类: ``` public class MemoAdapter extends RecyclerView.Adapter<MemoAdapter.ViewHolder> { private List<Memo> memoList; public MemoAdapter(List<Memo> memoList) { this.memoList = memoList; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.memo_item, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { Memo memo = memoList.get(position); holder.titleTextView.setText(memo.getTitle()); holder.contentTextView.setText(memo.getContent()); holder.dateTextView.setText(memo.getDate()); } @Override public int getItemCount() { return memoList.size(); } public static class ViewHolder extends RecyclerView.ViewHolder { public TextView titleTextView; public TextView contentTextView; public TextView dateTextView; public ViewHolder(View itemView) { super(itemView); titleTextView = itemView.findViewById(R.id.memo_title); contentTextView = itemView.findViewById(R.id.memo_content); dateTextView = itemView.findViewById(R.id.memo_date); } } } ``` 数据库帮助类: ``` public class MemoDbHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "memo.db"; private static final int DATABASE_VERSION = 1; private static final String SQL_CREATE_MEMO_TABLE = "CREATE TABLE " + MemoContract.MemoEntry.TABLE_NAME + " (" + MemoContract.MemoEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + MemoContract.MemoEntry.COLUMN_TITLE + " TEXT NOT NULL," + MemoContract.MemoEntry.COLUMN_CONTENT + " TEXT," + MemoContract.MemoEntry.COLUMN_DATE + " TEXT NOT NULL)"; public MemoDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_MEMO_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // not implemented yet } } ``` 备忘录操作类: ``` public class MemoDao { private SQLiteDatabase db; public MemoDao(Context context) { MemoDbHelper dbHelper = new MemoDbHelper(context); db = dbHelper.getWritableDatabase(); } public List<Memo> getAllMemos() { List<Memo> memoList = new ArrayList<>(); Cursor cursor = db.query( MemoContract.MemoEntry.TABLE_NAME, null, null, null, null, null, MemoContract.MemoEntry.COLUMN_DATE + " DESC"); while (cursor.moveToNext()) { long id = cursor.getLong(cursor.getColumnIndex(MemoContract.MemoEntry._ID)); String title = cursor.getString(cursor.getColumnIndex(MemoContract.MemoEntry.COLUMN_TITLE)); String content = cursor.getString(cursor.getColumnIndex(MemoContract.MemoEntry.COLUMN_CONTENT)); String date = cursor.getString(cursor.getColumnIndex(MemoContract.MemoEntry.COLUMN_DATE)); Memo memo = new Memo(id, title, content, date); memoList.add(memo); } cursor.close(); return memoList; } public void addMemo(Memo memo) { ContentValues values = new ContentValues(); values.put(MemoContract.MemoEntry.COLUMN_TITLE, memo.getTitle()); values.put(MemoContract.MemoEntry.COLUMN_CONTENT, memo.getContent()); values.put(MemoContract.MemoEntry.COLUMN_DATE, memo.getDate()); db.insert(MemoContract.MemoEntry.TABLE_NAME, null, values); } public void updateMemo(Memo memo) { ContentValues values = new ContentValues(); values.put(MemoContract.MemoEntry.COLUMN_TITLE, memo.getTitle()); values.put(MemoContract.MemoEntry.COLUMN_CONTENT, memo.getContent()); values.put(MemoContract.MemoEntry.COLUMN_DATE, memo.getDate()); String selection = MemoContract.MemoEntry._ID + " = ?"; String[] selectionArgs = { String.valueOf(memo.getId()) }; db.update(MemoContract.MemoEntry.TABLE_NAME, values, selection, selectionArgs); } public void deleteMemo(long id) { String selection = MemoContract.MemoEntry._ID + " = ?"; String[] selectionArgs = { String.valueOf(id) }; db.delete(MemoContract.MemoEntry.TABLE_NAME, selection, selectionArgs); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值