Search code examples
navigationscreenrubymotion

Navigating from one screen to another screen in Android using RubyMotion


In the MainActivity.rb class, I have written this code to handle a button click:

 def onClick(view)
     puts "coming here"
    if view.getId == @button_id
      puts @text_box_value.getText.toString
    elsif view.getId == @register_id
      puts @text_box.getText.toString
  #intent will describes what operation to be performed
  i = Android::Content::Intent.new(getApplicationContext, RegisterActivity)
  startActivity(i)
    end
  end

I added the activity in the AndroidManifest.xml file, yet it is showing this error:

android.content.ActivityNotFoundException: Unable to find explicit activity class

I am struggling with this but i didn't find any link in RubyMotion.


Solution

  • Try adding this to your Rakefile

    app.sub_activities = ['RegisterActivity']
    

    Also instead of using getApplicationContext you could use self

    Also try using start_activity instead.