- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
该应用程序会短暂打开一个白屏,然后几乎立即关闭。我会说时间范围大约是 1-2 秒。
我尝试过卸载应用程序、清除缓存等。
调试应用程序时,我没有看到任何突出的内容。这是应用程序打开/关闭期间涉及的堆栈跟踪。
我尝试在 MainActivity 的 OnCreate() 中放置一个断点,但它从未被击中。它几乎看起来好像没有到达 MainActivity。
是什么导致了这种性质?
09-30 09:02:42.225: E/WiFiOffloadingService(1189): setisWifiOntrue
09-30 09:02:42.225: E/WiFiOffloadingService(1189): [W Offloading] getWifiOffloadingStart0
09-30 09:02:42.225: E/WiFiOffloadingService(1189): setisWifiAPOn true
09-30 09:02:42.395: E/jdwp(13206): Failed sending reply to debugger: Broken pipe
09-30 09:02:42.835: E/BatteryObserver(1189): usb Uevent not necessary.
09-30 09:02:44.525: E/[LGHome]NumberBadge.LGUnreadLgeEmailsBadge(1619): [LGUnreadLgeEmailsBadge.java:188:countUnreadItems()]Could not get cursor from provider for com.lge.email
09-30 09:02:44.555: E/[LGHome]NumberBadge(1619): [LGNumberBadge.java:123:handleMessage()]MSG_RESPOND_RESULT_FROM_PROVIDER_FAILED
09-30 09:02:47.755: E/BatteryObserver(1189): usb Uevent not necessary.
09-30 09:02:47.945: E/LocSvc_afw(923): V/Entering int loc_inject_location(double, double, float) line 478
09-30 09:02:47.945: E/LocSvc_eng(923): I/===> int loc_eng_inject_location(loc_eng_data_s_type&, double, double, float) line 1941
09-30 09:02:47.945: E/LocSvc_afw(923): V/Exiting int loc_inject_location(double, double, float) line 502 0
更新:
在我尝试将 PictureEditActivity 从 Fragment 转换为 Activity 后,该应用程序最初以此类行为开始。我修改了 FeedActivity 和 PictureEditActivity 中的代码以保持功能。
由于错误,我已恢复到错误之前的先前代码,但行为仍然存在。
已解决
在另一台设备上测试该应用程序后出现错误。我将此错误追溯到我的应用程序另一部分中涉及 ParseDB 和注册多个子类的一行代码。
09-30 16:44:58.695: E/AndroidRuntime(23450): FATAL EXCEPTION: main
09-30 16:44:58.695: E/AndroidRuntime(23450): java.lang.RuntimeException: Unable to create application com.p.main.InitializeApplication: java.lang.IllegalArgumentException: Default constructor for class com.p.model.PUpload is not accessible.
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.p.main"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".InitializeApplication"
android:allowBackup="true"
android:icon="@drawable/p_logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SignUpActivity"
android:label="@string/title_activity_sign_up"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
</activity>
<activity
android:name=".NavigationActivity"
android:label="@string/title_activity_navigation"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
</activity>
<activity
android:name=".FeedActivity"
android:label="@string/title_activity_feed"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
</activity>
<activity
android:name=".UserActivity"
android:label="@string/title_activity_user"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
</activity>
<activity
android:name=".PictureEditActivity"
android:label="@string/title_activity_picture_edit"
android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
</activity>
</application>
</manifest>
主 Activity
public class MainActivity extends Activity implements OnClickListener {
Button btnSignIn, btnSignUp;
EditText etUsername, etPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSignIn = (Button) findViewById(R.id.btnSignIn);
btnSignIn.setOnClickListener(this);
btnSignUp = (Button) findViewById(R.id.btnSignUp);
btnSignUp.setOnClickListener(this);
etUsername = (EditText) findViewById(R.id.editTextSignInUsername);
etPassword = (EditText) findViewById(R.id.editTextSignInPassword);
// Check if there is a currently logged in user
// and they are linked to a Facebook account.
final ParseUser currentUser = ParseUser.getCurrentUser();
if ((currentUser != null)) {
// you can add this line &&
// ParseFacebookUtils.isLinked(currentUser)) to if statement
// if you want to make sure the user is also linked to facebook
// account
// Go to the user info activity
showPrimaryActivity();
finish();
}
}
@Override
public void onResume() {
super.onResume(); // Always call the superclass method first
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btnSignIn:
String username = etUsername.getText().toString().toLowerCase()
.trim();
String password = etPassword.getText().toString().toLowerCase()
.trim();
try {
if (username.isEmpty() || password.isEmpty()) {
if (username.isEmpty()) {
etUsername.setHintTextColor(getResources().getColor(
R.color.red));
etUsername.setHint("Enter Username");
}
if (password.isEmpty()) {
etPassword.setHintTextColor(getResources().getColor(
R.color.red));
etPassword.setHint("Enter Password");
}
}
} finally {
if (!username.isEmpty() || !password.isEmpty()) {
ParseUser.logInInBackground(username, password,
new LogInCallback() {
public void done(ParseUser user,
ParseException e) {
if (user != null) {
showPrimaryActivity();
finish();
// Hooray! The user is logged in.
} else {
etUsername.getText().clear();
etUsername
.setHintTextColor(getResources()
.getColor(R.color.red));
etUsername.setHint("Invalid Username");
etPassword.getText().clear();
etPassword
.setHintTextColor(getResources()
.getColor(R.color.red));
etPassword.setHint("Invalid Password");
Log.e("LOGIN FAILED",
"FAILED TO LOG IN");
// Signup failed. Look at the
// ParseException to see what happened.
}
}
});
}
}
break;
case R.id.btnSignUp:
Intent intent1 = new Intent(this, SignUpActivity.class);
startActivity(intent1);
break;
}
}
private void showPrimaryActivity() {
Intent intent = new Intent(this, NavigationActivity.class);
startActivity(intent);
}
}
导航 Activity
public class NavigationActivity extends FragmentActivity implements
TabHost.OnTabChangeListener {
private TabHost mTabHost;
private HashMap<String, TabInfo> mapTabInfo = new HashMap<String, TabInfo>();
private TabInfo mLastTab = null;
Context context;
private class TabInfo {
private String _tag;
private int _labelId;
private int _drawableId;
@SuppressWarnings("rawtypes")
private Class _class;
private Bundle _args;
private Fragment _fragment;
@SuppressWarnings("rawtypes")
TabInfo(int labelID, int drawableId, Class cl, Bundle args) {
this._tag = "tab" + labelID;
this._labelId = labelID;
this._drawableId = drawableId;
this._class = cl;
this._args = args;
}
public int get_labelId() {
return _labelId;
}
public int get_drawableId() {
return _drawableId;
}
@SuppressWarnings("rawtypes")
public Class get_class() {
return _class;
}
public Fragment get_fragment() {
return _fragment;
}
public String get_tag() {
return _tag;
}
}
class TabFactory implements TabContentFactory {
private final Context mContext;
/**
* @param context
*/
public TabFactory(Context context) {
mContext = context;
}
/**
* (non-Javadoc)
*
* @see android.widget.TabHost.TabContentFactory#createTabContent(java.lang.String)
*/
public View createTabContent(String tag) {
View v = new View(mContext);
v.setMinimumWidth(0);
v.setMinimumHeight(0);
return v;
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
ViewGroup vg = (ViewGroup) findViewById(R.id.main_root);
context = this;
// Step 2: Setup TabHost
initialiseTabHost(savedInstanceState);
if (savedInstanceState != null) {
// set the tab as per the saved state
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
}
}
@Override
public void onResume() {
super.onResume();
}
private void showLoginActivity() {
Intent intent = new Intent(context, MainActivity.class);
startActivity(intent);
}
protected void onSaveInstanceState(Bundle outState) {
outState.putString("tab", mTabHost.getCurrentTabTag()); // save the tab
// selected
super.onSaveInstanceState(outState);
}
/**
* Step 2: Setup TabHost
*/
private void initialiseTabHost(Bundle args) {
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup();
mTabHost.getTabWidget().setDividerDrawable(null);
addTab(R.string.lbl_title, R.drawable.ico_list, FeedActivity.class,
args);
addTab(R.string.lbl_user, R.drawable.ico_person, UserActivity.class,
args);
// Default to first tab
mTabHost.setCurrentTabByTag("tab" + R.string.lbl_title);
this.onTabChanged("tab" + R.string.lbl_title);
mTabHost.setOnTabChangedListener(this);
}
private void addTab(int labelID, int drawableId, Class cl, Bundle args) {
TabInfo tabInfo = null;
tabInfo = new TabInfo(labelID, drawableId, cl, args);
this.mapTabInfo.put(tabInfo.get_tag(), tabInfo);
TabHost.TabSpec spec = mTabHost.newTabSpec(tabInfo._tag);
View tabIndicator = LayoutInflater.from(this).inflate(
R.layout.tab_indicator,
(ViewGroup) findViewById(android.R.id.tabs), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(tabInfo.get_labelId());
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(tabInfo.get_drawableId());
spec.setIndicator(tabIndicator);
// Attach a Tab view factory to the spec
spec.setContent(this.new TabFactory(this));
String tag = spec.getTag();
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
tabInfo._fragment = this.getSupportFragmentManager().findFragmentByTag(
tag);
if (tabInfo._fragment != null && !tabInfo._fragment.isDetached()) {
FragmentTransaction ft = this.getSupportFragmentManager()
.beginTransaction();
ft.detach(tabInfo._fragment);
ft.commit();
this.getSupportFragmentManager().executePendingTransactions();
}
mTabHost.addTab(spec);
}
public void onTabChanged(String tag) {
TabInfo newTab = this.mapTabInfo.get(tag);
if (mLastTab != newTab) {
FragmentTransaction ft = this.getSupportFragmentManager()
.beginTransaction();
if (mLastTab != null) {
if (mLastTab._fragment != null) {
ft.detach(mLastTab._fragment);
}
}
if (newTab != null) {
if (newTab.get_fragment() == null) {
newTab._fragment = Fragment.instantiate(this, newTab
.get_class().getName(), newTab._args);
ft.add(R.id.realtabcontent, newTab.get_fragment(),
newTab._tag);
} else {
ft.attach(newTab.get_fragment());
}
}
mLastTab = newTab;
ft.commit();
this.getSupportFragmentManager().executePendingTransactions();
}
}
}
FeedFragment
public class FeedActivity extends Fragment implements OnClickListener {
ImageView m_ImageView;
ImageButton btnCamera, btnGallery;
private final String TAG_CAMERA_FRAGMENT = "camera_fragment";
private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
private Uri fileUri;
public static final int MEDIA_TYPE_IMAGE = 1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.activity_feed, container, false);
btnCamera = (ImageButton) view.findViewById(R.id.btn_Camera);
btnCamera.setOnClickListener(this);
btnGallery = (ImageButton) view.findViewById(R.id.btn_Gallery);
btnGallery.setOnClickListener(this);
return view;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_Camera:
Log.e("CAMERA", "CAMERA BUTTON PRESSED");
takePicture();
break;
case R.id.btn_Gallery:
Log.e("Gallery", "GALLERY BUTTON PRESSED");
break;
}
}
public void takePicture() {
// create Intent to take a picture and return control to the calling
// application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == getActivity().RESULT_OK) {
Log.e("ONACTIVITYRESULT",
"-----------------RESULT_OK----------------");
Bundle bundle = new Bundle();
bundle.putParcelable("URI", fileUri);
Fragment fragment = new PictureEditActivity();
fragment.setArguments(bundle);
// Intent intent = new Intent(getActivity(),
// PictureEditActivity.class);
// intent.putExtra("BUNDLE", bundle);
// startActivity(intent);
getFragmentManager()
.beginTransaction()
.replace(R.id.contentFragment, fragment,
TAG_CAMERA_FRAGMENT).commit();
if (fileUri != null) {
Log.e("CAMERA", "Image saved to:\n" + fileUri);
Log.e("CAMERA", "Image path:\n" + fileUri.getPath());
}
} else if (resultCode == getActivity().RESULT_CANCELED) {
Log.e("ONACTIVITYRESULT",
"-----------------RESULT_CANCELLED----------------");
} else {
}
}
}
/** Create a file Uri for saving an image or video */
private static Uri getOutputMediaFileUri(int type) {
return Uri.fromFile(getOutputMediaFile(type));
}
/** Create a File for saving an image or video */
private static File getOutputMediaFile(int type) {
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
File mediaStorageDir = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"P");
// This location works best if you want the created images to be shared
// between applications and persist after your app has been uninstalled.
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.d("P", "failed to create directory");
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
.format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE) {
mediaFile = new File(mediaStorageDir.getPath() + File.separator
+ "IMG_" + timeStamp + ".jpg");
} else {
return null;
}
return mediaFile;
}
}
图片编辑
public class PictureEditActivity extends Fragment implements OnClickListener {
ImageView m_ImageView;
FrameLayout m_Layout;
LinearLayout l_Layout, d_Layout;
ImageButton btnBorder, btnSticker, btnEffect, btnAccept, btnMust1,
btnMust2, btnBorderHome, btnStickerHome, btnDraw;
ImageButton btnDrawColorRed, btnDrawColorOrange, btnDrawColorYellow,
btnDrawColorGreen, btnDrawColorBlue, btnDrawColorIndigo,
btnDrawColorViolet, btnDrawColorPink, btnDrawColorPurple,
btnDrawColorBlack, btnDrawColorWhite, btnDrawColorBrown;
HorizontalScrollView home_hScrollView, border_hScrollView,
sticker_hScrollView, random_hView;
Context context;
CustomPaintView p_View;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_picture_edit, container,
false);
p_View = new CustomPaintView(getActivity());
m_Layout = (FrameLayout) view.findViewById(R.id.root_layout);
l_Layout = (LinearLayout) view
.findViewById(R.id.horizontalScrollbar_Layout);
d_Layout = (LinearLayout) view
.findViewById(R.id.linearLayoutDrawDetail);
home_hScrollView = (HorizontalScrollView) view
.findViewById(R.id.horizontalScrollViewHome);
border_hScrollView = (HorizontalScrollView) view
.findViewById(R.id.horizontalScrollViewBorder);
sticker_hScrollView = (HorizontalScrollView) view
.findViewById(R.id.horizontalScrollViewSticker);
btnBorder = (ImageButton) view.findViewById(R.id.imageButtonBorder);
btnBorder.setOnClickListener(this);
btnSticker = (ImageButton) view.findViewById(R.id.imageButtonSticker);
btnSticker.setOnClickListener(this);
btnAccept = (ImageButton) view.findViewById(R.id.btn_Accept);
btnAccept.setOnClickListener(this);
btnMust1 = (ImageButton) view.findViewById(R.id.imageButton1);
btnMust1.setOnClickListener(this);
btnMust2 = (ImageButton) view.findViewById(R.id.imageButton2);
btnMust2.setOnClickListener(this);
btnDraw = (ImageButton) view.findViewById(R.id.imageButtonDraw);
btnDraw.setOnClickListener(this);
btnBorderHome = (ImageButton) view
.findViewById(R.id.imageButtonBorderHome);
btnBorderHome.setOnClickListener(this);
btnStickerHome = (ImageButton) view
.findViewById(R.id.imageButtonStickerHome);
btnStickerHome.setOnClickListener(this);
// COLOR BUTTONS
btnDrawColorRed = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorRed);
btnDrawColorRed.setOnClickListener(this);
btnDrawColorOrange = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorOrange);
btnDrawColorOrange.setOnClickListener(this);
btnDrawColorYellow = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorYellow);
btnDrawColorYellow.setOnClickListener(this);
btnDrawColorGreen = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorGreen);
btnDrawColorGreen.setOnClickListener(this);
btnDrawColorBlue = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorBlue);
btnDrawColorBlue.setOnClickListener(this);
btnDrawColorIndigo = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorIndigo);
btnDrawColorIndigo.setOnClickListener(this);
btnDrawColorViolet = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorViolet);
btnDrawColorViolet.setOnClickListener(this);
btnDrawColorPink = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorPink);
btnDrawColorPink.setOnClickListener(this);
btnDrawColorPurple = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorPurple);
btnDrawColorPurple.setOnClickListener(this);
btnDrawColorBlack = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorBlack);
btnDrawColorBlack.setOnClickListener(this);
btnDrawColorWhite = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorWhite);
btnDrawColorWhite.setOnClickListener(this);
btnDrawColorBrown = (ImageButton) view
.findViewById(R.id.imageButtonDrawColorBrown);
btnDrawColorBrown.setOnClickListener(this);
// Bundle extras = getIntent().getExtras();
// Uri fileUri = extras.getParcelable("URI");
// //m_ImageView = (ImageView) findViewById(R.id.imageViewEdit);
// previewCapturedImage(fileUri);
return view;
}
/*
* Display image from a path to ImageView
*/
private void previewCapturedImage(Uri fileUri) {
try {
// bimatp factory
BitmapFactory.Options options = new BitmapFactory.Options();
// downsizing image as it throws OutOfMemory Exception for larger
// images
options.inSampleSize = 2;
Bitmap bitmap = BitmapFactory
.decodeFile(fileUri.getPath(), options);
Matrix matrix = new Matrix();
matrix.postRotate(90);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
m_ImageView.setImageBitmap(bitmap);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.imageButtonBorder:
// CustomImageView m_View = new CustomImageView(getActivity(),
// R.drawable.p_logo);
// m_Layout.addView(m_View);
l_Layout.removeAllViews();
l_Layout.addView(border_hScrollView);
break;
case R.id.imageButtonSticker:
l_Layout.removeAllViews();
l_Layout.addView(sticker_hScrollView);
break;
case R.id.btn_Accept:
finalizeBitmap(m_Layout);
Log.e("IMAGE SAVED", "IMAGE SAVED");
break;
case R.id.imageButton1:
CustomImageView m_View = new CustomImageView(getActivity(),
R.drawable.must1);
m_Layout.addView(m_View);
break;
case R.id.imageButton2:
CustomImageView m_View1 = new CustomImageView(getActivity(),
R.drawable.must2);
m_Layout.addView(m_View1);
break;
case R.id.imageButtonBorderHome:
l_Layout.removeAllViews();
l_Layout.addView(home_hScrollView);
break;
case R.id.imageButtonStickerHome:
l_Layout.removeAllViews();
l_Layout.addView(home_hScrollView);
break;
case R.id.imageButtonDraw:
// CustomPaintView p_View = new CustomPaintView(getActivity());
m_Layout.addView(p_View);
l_Layout.removeAllViews();
l_Layout.addView(d_Layout);
case R.id.imageButtonDrawColorRed:
p_View.setColor("#FF0000");
break;
case R.id.imageButtonDrawColorOrange:
p_View.setColor("#FF3300");
break;
case R.id.imageButtonDrawColorYellow:
p_View.setColor("#FFFF00");
break;
case R.id.imageButtonDrawColorGreen:
p_View.setColor("#009900");
break;
case R.id.imageButtonDrawColorBlue:
p_View.setColor("#0000FF");
break;
case R.id.imageButtonDrawColorIndigo:
p_View.setColor("#9966FF");
break;
case R.id.imageButtonDrawColorViolet:
p_View.setColor("#660066");
break;
case R.id.imageButtonDrawColorPink:
p_View.setColor("#FF0066");
break;
case R.id.imageButtonDrawColorPurple:
p_View.setColor("#333399");
break;
case R.id.imageButtonDrawColorWhite:
p_View.setColor("#FFFFFF");
break;
case R.id.imageButtonDrawColorBlack:
p_View.setColor("#000000");
break;
case R.id.imageButtonDrawColorBrown:
p_View.setColor("#663300");
break;
}
}
public void finalizeBitmap(View view) {
view.setDrawingCacheEnabled(true);
view.buildDrawingCache(true);
Bitmap bitmap = view.getDrawingCache();
saveToInternalStorage(bitmap);
}
private void saveToInternalStorage(Bitmap bitmapImage) {
ContextWrapper cw = new ContextWrapper(getActivity());
File root = new File(Environment.getExternalStorageDirectory()
+ File.separator + "Pictures" + File.separator + "P"
+ File.separator);
if (!root.exists()) {
root.mkdirs();
Log.e("ROOT", "DIRECTORY DOES NOT EXIST");
} else {
Log.e("ROOT", "DIRECTORY EXISTS");
File sdImageMainDirectory = new File(root, "p_"
+ (System.currentTimeMillis() / 1000L) + ".png");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(sdImageMainDirectory);
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(sdImageMainDirectory));
getActivity().sendBroadcast(intent);
Log.e("DIRECTORY", "" + sdImageMainDirectory.getAbsolutePath());
getActivity().getSupportFragmentManager().beginTransaction()
.remove(this).commit();
// change activity to something to share the picture
}
}
}
最佳答案
if ((currentUser != null)) {
showPrimaryActivity();
finish(); //remove this
}
从 onCreate()
的代码中删除 finish()
,它会使您的应用程序关闭......
关于android - 应用程序立即打开和关闭,不会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26121663/
我开始学习 Oracle JavaSE 认证考试。 我创建了一个 IntelliJ Idea 项目来处理我的训练源代码。我想尽量减少 IntelliJ Idea 的帮助。 我只想使用:颜色语法、终端选
默认情况下,.DPR 和 .DPROJ 的文件扩展名描述是相同的,因此在资源管理器中打开具有相同基本名称的项目文件时,两个文件描述都会列为“Delphi 项目文件”,这提供了一个选择开发人员 - 要打
我目前正在从 android 网站了解 Navigation Drawer,我正在使用他们的示例 http://developer.android.com/training/implementing-
我需要帮助。 我在 A3:A500 列中有单词和数字 我需要改变他们的名字。 如果单元格包含单词“previ”,则如果单元格是数字,则将字母“p”放入新列中。如果它是一个词,那么不要放“p” ...就
我正在尝试编写一些 VBA,它允许按钮添加一个空行,保持相同的格式,就在 SUM 公式所在的行上方。 到目前为止,我实现了创建一个空行,但我不知道如何实现代码以让该新行继承相同的格式样式(包括边框和格
我在共享网络驱动器上有两个工作簿: 工作簿 A(表) 工作簿 B(数据透视表 - 连接到源工作簿 A) 我正在尝试,当打开 Workbook B 时,运行宏并执行以下操作: 取消保护工作簿 B 上的某
我正在开发一个需要在在线/离线模式下进行测试的应用程序,所以我想知道是否有任何方法可以打开/关闭 iPad 模拟器的互联网连接(不关闭我的 MAC 的互联网服务)。请帮忙 最佳答案 不,模拟器使用与您
我需要对目录的所有文件执行我的脚本(搜索)。以下是有效的方法。我只是问哪个最好。 (我需要格式的文件名:parsedchpt31_4.txt) 全局: my $parse_corpus; #(for
在我的代码中,我想有条件地执行一些操作: #ifdef DEBUG NSLog(@"I'm in debug mode"); #endif 我已配置“项目”->“编辑项目设置”->“构建”选项卡,以便
我编写了一个小程序来比较笔记本电脑的性能。为了使程序CPU更加密集,我用一些多线程代码(通过Parallel API实现)实现了Rabin-Karp模式匹配算法。 我注意到,当在关闭编译器优化标志的情
使用以下代码来关闭模态并打开第二个模态。总是遇到同样的问题可以关闭一个但不能打开第二个,或者如果我更改顺序我可以打开一个但不能关闭另一个。 (我想我已经尝试过101版本了)。如果有人能帮忙的话。
blue sky 默认情况下,当指针悬停时显示标题。 是否可以切换它,例如: $('#button').on('click', function(){ if (something) {turn
我正在编写一个简单的宏,它将打开、保存和关闭一个 Excel 文件(例如 myworkbook.xlsx),但我无法执行此操作。我的文件 myworkbook.xlsx 位于以下位置: C:\User
我正在加载两个 geoJson 层 - 出于测试目的,两个层都是相同的数据,但是是从两个不同的 json 文件中提取的。当我在图层 Controller 中打开和关闭图层时,图层的绘制顺序会发生变化。
我在我的设置 Activity 中发现,当用户单击 ToggleButton 时,它应该在整个应用程序中静音,但它不起作用。我在教程类中放入的 SoundPool onClick 按钮声音仍在 onC
我有一部双卡手机。如果我想打开飞行模式,两个 SIM 卡都会发生这种情况。 是否可以通过编程方式仅对一张SIM卡进行操作(用户可以选择两者之一)?我看到了here上的帖子,他们一直工作到 API 16
我目前正在开发一个带有一些 pipe() 和重定向的 C shell 程序。 我使用 dup2() stdout 和 stderr (1 & 2) 重定向。 当我用 int fd = open("te
Jquery: 有没有办法捕获浏览器打开“打开/另存为”对话框时触发的事件? Open/Save dialog example http://qpack.orcanos.com/helpcenter/
我知道你可以用 window.close 关闭 window.open 但还有其他方法吗?我有一个打开 facebook 连接的弹出窗口,我想在用户连接到 facebook 时关闭弹出窗口,然后刷新父
我搜索一个事件,如果不存在,则搜索一种方法来了解屏幕是否关闭(电源选项 - 控制面板 - 关闭显示设置)。 这些解决方案都不适合我。 所以要么我在某个地方错了,要么就是不合适。 How to get
我是一名优秀的程序员,十分优秀!