This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Android Code doesn't gives the expected output  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this project there are no errors whatsover but the OUTPUT of mine
differs from that of the original.

HERE is the original tutorial link:-
https://developer.android.com/training/animation/screen-slide.html

and HERE is my code:-

https://gist.github.com/pamnanaimanish169/3125f456c200430c474c8d1f7690c0b6

Machine Enviornment:- Windows 10(64-bit)

Android emulator:-Nexus 4 API 21

I executed the app and it run successfully and gave the output:-

"my_ouput_screen_slide_new.jpg"

while the expected output is:-

"anim_screenslide_gif.gif"

anim_screenslide_gif.gif
[Thumbnail for anim_screenslide_gif.gif]
 
Bartender
Posts: 1856
81
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few quick notes:
1) I did not see "my_ouput_screen_slide_new.jpg", maybe it did not get attached.
2) Your project has more then you have put on GitHub include the "res", "lib" directories and possible more.
3) I would kind of suspect that your output would not be exactly the same as the source code for this project was last update in 2012.
4) Have you downloaded the sample created by Google/Android to see if it produces the same result as your project?
 
Pete Letkeman
Bartender
Posts: 1856
81
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I missed this in my previous post, sorry

Welcome to CodeRanch Manish.

I hope that you will find this community knowledgeable, sharing and welcoming.

One more follow up question:
Are you using Android Studio for this project, Eclipse or something else?
 
Manish Pamnani
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pete Letkeman wrote:I missed this in my previous post, sorry

Welcome to CodeRanch Manish.

I hope that you will find this community knowledgeable, sharing and welcoming.

One more follow up question:
Are you using Android Studio for this project, Eclipse or something else?



Thanks for welcoming me!!

I am using Android Studio Version 3.0.1
 
Manish Pamnani
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pete Letkeman wrote:A few quick notes:
1) I did not see "my_ouput_screen_slide_new.jpg", maybe it did not get attached.
2) Your project has more then you have put on GitHub include the "res", "lib" directories and possible more.
3) I would kind of suspect that your output would not be exactly the same as the source code for this project was last update in 2012.
4) Have you downloaded the sample created by Google/Android to see if it produces the same result as your project?



->Here is the "my_output_screen_slide_new.jpg" file:-
https://photos.app.goo.gl/BSSPPTNBArBN6DrF2

->Yes i downloaded the sample provided by the Android/Google, Here is the link to it:-
[urlhttps://github.com/pamnanaimanish169/AnimationsDem02][/url]


->Here is the link to the Github project which includes "res" , "lib":-
https://github.com/pamnanaimanish169/Screen_slide_new

and Thanks for replying!!
my_ouput_screen.jpg
[Thumbnail for my_ouput_screen.jpg]
 
Pete Letkeman
Bartender
Posts: 1856
81
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, there are a few different things occurring here:

1) All of your source Java files should to be in the same directory. So ScreenSlideActivity.java and ScreenSlidePageFragment.java should be in the same location as MainActivity.java.
   Later on when you get into packages you will see how/where files can be moved.
2) ScreenSlideActivity.java and ScreenSlidePageFragment.java do not have Package statements. Package statements should be the first line in the source file with the exception of comments.
3) Your MainActivity does not contain code to load any other activity.
4) All activities need to be registered in AndroidManifest.xml

You can read more about packages here https://docs.oracle.com/javase/tutorial/java/package/index.html.

This tutorial should help you get started with having one activity load another activity https://developer.android.com/training/basics/firstapp/starting-activity.html which should help with points 3 and 4.
 
Manish Pamnani
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pete Letkeman wrote:Okay, there are a few different things occurring here:

1) All of your source Java files should to be in the same directory. So ScreenSlideActivity.java and ScreenSlidePageFragment.java should be in the same location as MainActivity.java.
   Later on when you get into packages you will see how/where files can be moved.
2) ScreenSlideActivity.java and ScreenSlidePageFragment.java do not have Package statements. Package statements should be the first line in the source file with the exception of comments.
3) Your MainActivity does not contain code to load any other activity.
4) All activities need to be registered in AndroidManifest.xml

You can read more about packages here https://docs.oracle.com/javase/tutorial/java/package/index.html.

This tutorial should help you get started with having one activity load another activity https://developer.android.com/training/basics/firstapp/starting-activity.html which should help with points 3 and 4.



Here is the best that i can come upto while following your advice:-

-> i moved all of the .java files into the folder where my MainActivity.java existed, here is the new directory:-

a)Screen_slide_new\app\src\main\java\com\example\manish\screen_slide_new\MainActivity.java
b)Screen_slide_new\app\src\main\java\com\example\manish\screen_slide_new\ScreenSlideActivity.java
c)Screen_slide_new\app\src\main\java\com\example\manish\screen_slide_new\ScreenSlidePageFragment.java

->I imported the package statements in ScreenSlideActivity.java and ScreenSlidePageFragment.java files:-

"ScreenSlideActivity.java":-


"ScreenSlidePAgeFragment.java":-



->I registered all the activities in ANdroidManifest.xml:
"AndroidManifest.xml":-

I solved few of the problems but i can't figure out a way to call one activity from another while using a Fragment(although you provided the link which i appreciate).

Thanks for the help!!
 
Pete Letkeman
Bartender
Posts: 1856
81
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay Manish you are making some progress, which is good.

Here are a few different paths that you can do next:

Please back up your project before you do anything else.

Path 1
Start a new project leaving the current project as is so that you can come back to it later.

Here are a few different tutorials on how to start a new activity by clicking/pressing a button:
  • http://hmkcode.com/android-start-another-activity-within-the-same-application/
  • http://www.androidbegin.com/tutorial/android-button-click-new-activity-example/
  • http://tekeye.uk/android/examples/starting-a-second-activity
  • http://www.androiddocs.com/training/basics/firstapp/starting-activity.html
  • I do not know if any/all of these tutorials work as expected.

    Once you are able to create a Android program which only loads another activity then I suggest you look into how to load a fragment.
    Here are a few different tutorials on how to start/load a fragment:
  • http://www.vogella.com/tutorials/AndroidFragments/article.html
  • http://abhiandroid.com/ui/fragment
  • http://www.techotopia.com/index.php/Using_Fragments_in_Android_-_A_Worked_Example
  • https://www.developer.com/ws/android/programming/working-with-fragments-in-android-applications.html
  • I do not know if any/all of these tutorials work as expected.

    Once you know how to load a new activity and how to load a fragment in an that new activity you can then apply that knowledge to your original program.

    Path 2
    If you only need on activity then you could migrate some (all?) the code from from ScreenSlideActivity.java into MainActivity.java.
    Then as soon as your program starts the fragment ScreenSlidePageFragment would load.

    Path 3
    Download the sample program provided by Google/Android and remove what you do not want

    Path 4
    Restart at the beginning of the tutorial series found here https://developer.android.com/training/index.html going over everything once again.

    Please do not forget to back up your code before making changes to it. This should only take a few minutes to do as you simply need to copy the project files and place them somewhere else.
    The total size of this project is most is probably less then five mega bytes so you should have more then enough room on your system for this.
     
    Manish Pamnani
    Ranch Hand
    Posts: 56
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Pete Letkeman wrote:Okay Manish you are making some progress, which is good.

    Here are a few different paths that you can do next:

    Please back up your project before you do anything else.

    Path 1
    Start a new project leaving the current project as is so that you can come back to it later.

    Here are a few different tutorials on how to start a new activity by clicking/pressing a button:

  • http://hmkcode.com/android-start-another-activity-within-the-same-application/
  • http://www.androidbegin.com/tutorial/android-button-click-new-activity-example/
  • http://tekeye.uk/android/examples/starting-a-second-activity
  • http://www.androiddocs.com/training/basics/firstapp/starting-activity.html
  • I do not know if any/all of these tutorials work as expected.

    Once you are able to create a Android program which only loads another activity then I suggest you look into how to load a fragment.
    Here are a few different tutorials on how to start/load a fragment:
  • http://www.vogella.com/tutorials/AndroidFragments/article.html
  • http://abhiandroid.com/ui/fragment
  • http://www.techotopia.com/index.php/Using_Fragments_in_Android_-_A_Worked_Example
  • https://www.developer.com/ws/android/programming/working-with-fragments-in-android-applications.html
  • I do not know if any/all of these tutorials work as expected.

    Once you know how to load a new activity and how to load a fragment in an that new activity you can then apply that knowledge to your original program.

    Path 2
    If you only need on activity then you could migrate some (all?) the code from from ScreenSlideActivity.java into MainActivity.java.
    Then as soon as your program starts the fragment ScreenSlidePageFragment would load.

    Path 3
    Download the sample program provided by Google/Android and remove what you do not want

    Path 4
    Restart at the beginning of the tutorial series found here https://developer.android.com/training/index.html going over everything once again.

    Please do not forget to back up your code before making changes to it. This should only take a few minutes to do as you simply need to copy the project files and place them somewhere else.
    The total size of this project is most is probably less then five mega bytes so you should have more then enough room on your system for this.



    It seems like a lot of work but it also seems to be the prolonged solution that i wished!!
    I will definitely look into it!!
    And thanks for replying!!
     
    Pete Letkeman
    Bartender
    Posts: 1856
    81
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Manish Pamnani wrote:It seems like a lot of work but it also seems to be the prolonged solution that i wished!!


  • You are learning along the way so the next time will be able to complete a task like this quicker.
  • You only have to choose one path (maybe two), and I provided you with several. I'm not too sure which one will work best for you.
  • While I (or someone else) could complete the coding for you, here at CodeRanch we generally prefer to have people discover the solution themselves especially for new programmers.
       This is why I've provided you with links to tutorials which help to explain what is happening and how to do things.
       By doing you get more satisfaction and gain the knowledge needed for challenges in the future.
  • Manish Pamnani wrote:And thanks for replying!!


    You are welcome. Remember we all started somewhere and we are all in this journey together.
     
    Do not threaten THIS beaver! Not even with this tiny ad:
    Download Free Java APIs to Work with Office Files and PDF
    htttp://www.e-iceblue.com/free-apis.html
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!