我正在开发一个应用程序,我需要从相机中捕获图像.捕获后,我必须将位图转换为Base64.转换为Base64后,我必须将该字符串发送到SERVER.我正在使用以下代码执行此任务:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] b = baos.toByteArray();
base64Image = Base64.encodeToString(b,Base64.DEFAULT);
Run Code Online (Sandbox Code Playgroud)
问题:当我将Base64转换为图像时,我得到了不完整的图像.同样的结果发生在服务器上,我的图像没有完全从Base64 String重构.
请建议我的解决方案.我已经搜索了很多并获得了我正在使用的相同代码.
编辑:请看下面不完整的图片

代码用于捕获图像:
intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PHOTO);
Run Code Online (Sandbox Code Playgroud) 我有一个Edit Text数字只能介于两者之间0-59,没有其他数字会输入Edit Text,我试过text-watcher但没有成功.任何的想法?
12-26 14:59:39.715: E/AndroidRuntime(19494): FATAL EXCEPTION: main
12-26 14:59:39.715: E/AndroidRuntime(19494): java.lang.StackOverflowError
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.View.findViewById(View.java:10442)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.View.findViewById(View.java:10442)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.View.findViewById(View.java:10442)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.View.findViewById(View.java:10442)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.View.findViewById(View.java:10442)
12-26 14:59:39.715: E/AndroidRuntime(19494): at android.view.ViewGroup.findViewTraversal(ViewGroup.java:2765)
12-26 14:59:39.715: E/AndroidRuntime(19494): at …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我必须覆盖INCOMING CALL SCREEN.
当设备收到呼叫时,我必须显示我的应用程序的弹出窗口.我已经对这项任务进行了详细的研究.CALL POPOUT是一个使用相同功能的应用程序,但我没有得到源代码.
目前我没有几个模块可以通过它来获得INCOMING CALL的动作.
public class MyPhonestateListner extends PhoneStateListener {
Context context;
List<String> blockedNumberList = new ArrayList<String>();
BlockDataSource datasourceobj;
public MyPhonestateListner(Context context) {
super();
this.context = context;
}
@Override
public void onCallStateChanged(int state, String callingNumber) {
super.onCallStateChanged(state, callingNumber);
callingNumber = callingNumber.replace(" ", "");
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// handle out going call
// if(blockedNumberList.contains(callingNumber))
endCallIfBlocked(callingNumber);
break;
case TelephonyManager.CALL_STATE_RINGING:
// handle in coming call
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intentPhoneCall …Run Code Online (Sandbox Code Playgroud) 我正在使用ListView的自定义适配器,其中我有一个TextView和一个Spinner.从Spinner中选择值后,将该值复制到相应行列表的TextView之后.
问题是,由于我在ListView中有超过40个元素,当我选择第一个微调器并将值设置为相应的TextView时,在滚动时,在第10行TextView中可以看到相同的值.
在滚动时将值从第1个TextView复制到第10个TextView.
以下是我使用的代码:
public class AppListAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private List<App> mApps = Constants.list;
private Context _activity;
ArrayList<String> months=null;
ArrayAdapter<String> dataAdapter =null;
int spinerposition;
int viewposition;
int temp=0;
private int screenWidth;
/**
* Constructor.
*
* @param context the application context which is needed for the layout inflater
* @param screenWidth
*/
public AppListAdapter(Context context, int screenWidth) {
// Cache the LayoutInflate to avoid asking for a new one each time.
mInflater = LayoutInflater.from(context);
this._activity=context;
this.screenWidth …Run Code Online (Sandbox Code Playgroud) 我正在一个应用程序中工作,我正在使用此代码获取安装了我的设备的所有应用程序:
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory("com.myapp.MY_CATEGORY");
final List<ResolveInfo> pkgAppsList =getPackageManager().queryIntentActivities( mainIntent, 0);
Run Code Online (Sandbox Code Playgroud)
现在我想根据他们的类别对应用程序进行不同的分类.请建议我.
处理我们捕获图像并通过服务器上传的应用程序.应用程序在 Android和I Phone中.当我们从Android发布图像时,它们的数量是Kilo Bytes但是当我们从I Phone发布图像时它们是MB大小.
当我们在IPHONE 5上使用URL在浏览器上发布图像时,它们看起来很好,但是当我们在Android设备中下载该图像并在图像视图中显示时,它们会向左侧倾斜90度.
在Android或I Phone中下载图像后,我没有使用任何旋转代码.
在I Phone中,图像看起来很好.
从Android捕获的图像也是可见的.从I Phone中捕获的低分辨率图像也可以直接在Android中看到.
从Android上传的图片:
https://s3.amazonaws.com/WeddingApp/Weddingimage/933_6_stan.jpg
Run Code Online (Sandbox Code Playgroud)
从I Phone上传的图片:
https://s3.amazonaws.com/WeddingApp/Weddingimage/937_6_stan.jpg
public static boolean downloadFile(final String fileURL,File directory,Context CONTEXT){
try{
URL url = new URL(fileURL);
URLConnection ucon = url.openConnection();
ucon.setReadTimeout(35000);
ucon.setConnectTimeout(10000);
InputStream is = ucon.getInputStream();
BufferedInputStream inStream = new BufferedInputStream(is, 1024 * 5);
File file = directory;
if (file.exists())
{
file.delete();
}
file.createNewFile();
FileOutputStream outStream = new FileOutputStream(file);
byte[] buff = new byte[5 * 1024];
int len;
while ((len = inStream.read(buff)) != …Run Code Online (Sandbox Code Playgroud) 我需要用户定义的功能,可以将日期从当前时间排序到旧时间.
我有10个日期的列表,我想从上次最近的日期开始对这些日期进行排序.
目前我有一个逻辑,如果我们可以用毫秒来转换日期然后将它与当前毫秒相比较,最小毫秒将是最近的日期.那是,
CURRENT_MILLI_SECOND - A_DATE_CONVERTED_TO_MILLI_SECONDS = MILLI-SECONDS
Run Code Online (Sandbox Code Playgroud)
请建议我是否有人可以帮助我这个逻辑或任何其他逻辑... !!!
这是我从服务器获取的结果:
Thu Dec 27 11:02:43 GMT+05:30 2012
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用了ObjectChoiceField.选择很长,大多数选择是两行,这增加了高度,ObjectChoiceField使我的UI不稳定.我在Android中使用了" single line = true "属性,允许长文本行以省略号显示(...).
我可以在BlackBerry中这样做,因为不想在运行时更改高度.另外我不想使用自定义ObjectChoiceField.请根据我的条件建议我,我该怎么办.
目前我正在使用以下代码.
ObjectChoiceField _productLineOCF =new ObjectChoiceField("",_productLineArray,plSetTo1,Field.FIELD_RIGHT){
protected void layout(int width, int height) {
setMinimalWidth(width - 61);
super.layout(width, height);
}
};
Run Code Online (Sandbox Code Playgroud)
以上代码的示例输出:

我正在努力从我的应用程序中获取电话簿和SIM卡的所有联系人.我想将所有联系人存储在我的应用程序SQLite DB中.我正在使用的代码在正常条件下正常工作.在以下条件下遇到问题:
我的代码不向我提供这两种类型的联系人.我使用以下代码:
public void getDefaultContactsToDB(){
CallBackDatabase callbackDB = new CallBackDatabase(RequestCallBack.this);
callbackDB.open();
//clean the database before entering new values.
callbackDB.deleteTable(CallBackDatabase.DATABASE_TABLE);
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
Cursor cur1 = cr.query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?",
new String[]{id}, null);
while (cur1.moveToNext()) {
//to get the contact names
ArrayList<String> numbers= new ArrayList<String>();
String contactNoumber="";
String name=cur1.getString(cur1.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
if(name!=null){
Log.e("Name :", name);
if(name.equalsIgnoreCase("011999999999999999")){ …Run Code Online (Sandbox Code Playgroud) 它的简单但在我的应用程序中创建问题.我正在使用Implicit Intent 发送电子邮件,将IMAGE附加为附件.但是使用以下代码创建问题.
File file = new File(path);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("vnd.android.cursor.dir/email");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Wedding App");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Sharing image via email.");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file.toString()));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Run Code Online (Sandbox Code Playgroud)
创建崩溃:
02-22 12:20:47.561: E/ActivityThread(6317): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@417c1fc8 that was originally registered here. Are you missing a call to unregisterReceiver()?
02-22 12:20:47.561: E/ActivityThread(6317): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@417c1fc8 that was originally registered here. Are you missing a call to unregisterReceiver()?
02-22 12:20:47.561: E/ActivityThread(6317): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763) …Run Code Online (Sandbox Code Playgroud)