Categories
Android

Activity has leaked window that was originally added

这种现象在 Activity退出了,但是想Dialog之类的对话框没有dismiss()的情况下可能出现

参考:

http://our2848884.blog.163.com/blog/static/14685483420109319468177/

Categories
Android

PhoneGap 开发之Android

学校的移动应用比赛看重跨平台性,所以不得不转向PhoneGap来开发程序,虽然我还是爱Android的

两篇入门文章
基于PhoneGap的Android应用开发:Get started
http://mobile.51cto.com/android-273486.htm

PhoneGap快速上手 – 基于eclipse环境搭建、部署(图解)
http://www.javapk.net/phonegap-course-eclipse-demo/

基本是
先添加支持包,然后修改主Activity,最后就是写Web代码

Categories
Android

Android反编译

获取图片资源:
APK本身是压缩文件,所以直接解压可以获得图片资源文件

获取布局XML文件
用上述方法得到的XML打开后是乱码,
这时可以用apktool来反编译apk文件,可以活的正常的布局文件
https://code.google.com/p/android-apktool/

获得源代码
这个就最难了,一般签了名之后就比较难获得源码,但是不防一试
dex2jar
jd-gui
X-Jad

先用dex2jar把解压apk得到的dex文件反编译为jar文件,然后用jd-gui或者X-JAD查看

参考:
http://blog.csdn.net/xuejinwei0530/article/details/8296763
http://blog.csdn.net/zx19899891/article/details/7559201

Categories
Android

Android JavaMail API Notes

JavaMail API is quite useful,but how to use it in Android

We can use the javamail-android, it is a JavaMail port for the android platform

https://code.google.com/p/javamail-android/downloads/list
before you start coding,please download the three file in the following url:
https://code.google.com/p/javamail-android/downloads/list
additional.jar
mail.jar
activation.jar

Here is three url that is very helpful:
http://mrbool.com/how-to-work-with-java-mail-api-in-android/27800#ixzz2j94GWJiW

http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a

http://androidcodeexamples.blogspot.in/2012/05/android-send-email-via-gmail-actually.html

You may encount this problem
Could not find method javax.activation.DataHandler
This is because you use different version of mail.jar and activation.jar, please make sure you download the three file from the same place.
Here is an answer
http://stackoverflow.com/questions/13728421/java-mail-1-4-5-on-android

You may want to use the original version,however it can not run unless small modifictaion.
mail.jar
https://java.net/projects/javamail/pages/Home
activation.jar
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html#jaf-1.1.1-fcs-oth-JPR

Download Source code of JavaMail:
http://download.java.net/maven/2/com/sun/mail/javax.mail/
https://java.net/projects/javamail/pages/Home

Categories
Android

Android 获得Dialog中的数据

LayoutInflater layoutInflater = getLayoutInflater();
final View dialogView = layoutInflater.inflate(R.id.dialog);

然后在Dialog的设置按钮的onClick()方法中写入:

TextView text = (EditText)dialogView.findViewById(R.id.username_edit); //注意findViewById前面有特定的View
String textContent = text.getText().toString();
outView.setText(textContent); //outView就是需要写入数值的控件

LayoutInflater inflater =(LayoutInflater)getApplicationContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.course_custom_dialog, null);
AlertDialog.Builder builder2=new AlertDialog.Builder(MainDialogActivity.this);
builder2.setView(view);
builder2.setTitle(“添加课程”)
.setPositiveButton(“保存”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}

})
.setNegativeButton(“取消”, null)
.create().show();

两段代码来自网络

http://blog.csdn.net/starrexstar/article/details/7868324

http://my.oschina.net/laiwanshan/blog/99481

Categories
Android

Android 禁止屏幕旋转

屏幕旋转怪麻烦的
禁止方法为在每个需要禁止的Activity声明中添加如下语句中的一个

android:screenOrientation=”portrait”
android:screenOrientation=”landscape”

其中portrait 表示 纵向
landscape 表示 横向

Categories
Android

Android 重写菜单按钮