Posts

Showing posts with the label Android Activity

Android: No Activity Found To Handle Intent Error? How It Will Resolve

Answer : Add the below to your manifest: <activity android:name=".AppPreferenceActivity" android:label="@string/app_name"> <intent-filter> <action android:name="com.scytec.datamobile.vd.gui.android.AppPreferenceActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> in my case, i was sure that the action is correct, but i was passing wrong URL, i passed the website link without the http:// in it's beginning, so it caused the same issue, here is my manifest (part of it) <activity android:name=".MyBrowser" android:label="MyBrowser Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="com.dsociety.activities.MyBrowser" /> <category android:name...

Card Flip Animation Between Activities

Image
Answer : From what I've got you can't do exactly that same card flip between activities. BUT, as you might already know you need overridePendingTransition() in order to animate transition between activities (doc here). Now all you need is an animation resource to do the trick. I used these: fade_in.xml <?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <scale android:duration="200" android:fromXScale="0.0" android:fromYScale="1.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:startOffset="200" android:toXScale="1.0" android:toYScale="1.0" /> <alpha android:duration="1" android:fromAlpha="0.0" android:startOffset="200" andr...

About Android Launchmode "singleTask"

Image
Answer : You sound right. Why don't you test it. There is also this app that can help explain launch mode: https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode Sources are at https://github.com/gnorsilva/Activities-LaunchMode-demo The ActivityC will be removed from task1 and ActivityB becomes the top Activity. Yes, you are Right... ActivityC will be removed from i.e. the onDestroy method of the ActivityC will be called. Hence when the user launches Task 1 again, the ActivityB is shown rather than ActivityC. Have created 2 Tasks (Projects) and uploaded the same @ SendSpace. Try it out... If you look at androids documentation it says " A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task." This means that when you click the hom...

Android Center Text On Canvas

Image
Answer : Try the following: Paint textPaint = new Paint(); textPaint.setTextAlign(Paint.Align.CENTER); int xPos = (canvas.getWidth() / 2); int yPos = (int) ((canvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2)) ; //((textPaint.descent() + textPaint.ascent()) / 2) is the distance from the baseline to the center. canvas.drawText("Hello", xPos, yPos, textPaint); Center with Paint.getTextBounds() : private Rect r = new Rect(); private void drawCenter(Canvas canvas, Paint paint, String text) { canvas.getClipBounds(r); int cHeight = r.height(); int cWidth = r.width(); paint.setTextAlign(Paint.Align.LEFT); paint.getTextBounds(text, 0, text.length(), r); float x = cWidth / 2f - r.width() / 2f - r.left; float y = cHeight / 2f + r.height() / 2f - r.bottom; canvas.drawText(text, x, y, paint); } Paint.Align.CENTER doesn't mean that the reference point of the text is vertically centered. The reference point ...

Advantages Of Using Bundle Instead Of Direct Intent PutExtra() In Android

Answer : It makes little (if any difference). The code using an additional bundle is slightly heavier (it won't make any difference in any practical application) and slightly easier to manage, being more general. If one day you decide that - before sending information inside an intent - you want to serialize the data to database - it will be a bit cleaner to have a bundle that you can serialize, add to an intent and then feed to a PendingBundle - all with one object. [update] A clarification (because of some other answers). Extras is an additional bundle that each Intent might carry (but doesn't have to), so there is no alternative between using a bundle or not using it. You are using a bundle either way. The first time you use putExtra , a mExtras bundle inside Intent is initialized and all the following putExtra are delegated to it. The bundle itself is inaccessible to you (this is by design, to avoid certain kind of bugs). putExtras does not put your bundle...

Android OnBackPressed() Is Not Being Called?

Answer : This question is already answered, but I feel to clear something here in this topic. Most comments and answeres point out to use super.onBackPressed() and that this is the cause of the not working method onBackPressed() . But that is not correct and important to let other beginners know. The method onBackPressed() does not need to use super.onBackPressed() . onBackPressed() also works if somebody, for example, comment super.onBackPressed() out. As the questionier has written, he won´t use super.onBackPressed() because it will close the activity. So, the cause of this why it isn´t working, could be seperated into three possible causes: The Log doesn´t work because of a wrong filter in the logcat console The Toast dosn´t work because of the wrong passed context The OS is implemented wrong by the supplier. Usually, the toast works by passing the correct context. In the case of questioner, simply passing this . @Override public void onBackPressed() { Log.d...