Android : nullpointerexception in android app and doesnt send mail

on Saturday, January 31, 2015


i am developing android app in which we take some user information and capture signature and when we click share button it wii store in database and send email....but my app after store database app is stopped and does not send mail....thanks in advance


mShare.setOnClickListener(new OnClickListener() {



public void onClick(View v)
{
//mSignature.save(mView);

new CreateNewInformation().execute();
//sendmail();
Bitmap icon = mBitmap;

//Protected void sendmail();
String TO []= {Email.getText().toString(),"sourabhkabra960@gmail.com"};


// Intent shareIntent = new shareIntent();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
//shareIntent.putExtra(Intent.EXTRA_EMAIL,Address);
//shareIntent.putExtra(Intent.EXTRA_EMAIL,TO);
//shareIntent.putExtra(Intent.EXTRA_EMAIL,Address);
shareIntent.putExtra(Intent.EXTRA_SUBJECT,Name.getText().toString());
shareIntent.putExtra(Intent.EXTRA_TEXT,"amount recived="+AmtRec.getText().toString());

// shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(mypath)); //optional//use this when you want to send an image
shareIntent.setType("Text");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "Gmail"));
PackageManager pm = v.getContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{
if ((app.activityInfo.name).contains("android.gm"))
{
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
// shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
//shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
v.getContext().startActivity(shareIntent);
break;
}
}


// share = new Intent(Intent.ACTION_SEND)
shareIntent.setType("image/png");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, bytes);

File f = new File(Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.external_dir) + "/" +current);
try {
mypath.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
}
catch (IOException e) {
e.printStackTrace();
}




//shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
//startActivity(Intent.createChooser(shareIntent, "Share Image"));
}
});

0 comments:

Post a Comment