Posts

Showing posts from 2015

How to disable Activity and enable it programmatically?

In this example there are two activities declared in AndroidManifest.xml file. SetupActivity is enabled and MainActivity is disabled by default. <activity       android:name=”.SetupActivity”       android:label=”@string/app_name_setup”       android:icon=”@drawable/app_setup_icon”       android:enabled=”true”>          <intent-filter>              <action android:name=”android.intent.action.MAIN”/>              <category android:name=”android.intent.category.LAUNCHER”/>          </intent-filter> </activity> <activity       android:name=”.MainActivity”       android:label=”@string/app_name”       android:icon=”@string/app_icon”       android:enabled=”false”>          <intent-filter>              <action android:name=”android.intent.action.MAIN”/>              <category android:name=”android.intent.category.LAUNCHER”/>          </intent-filter> </activity> You can enable MainActivity by using f

How to inspect the values inside the route in ASP.Net MVC C#

public ActionResult Index() {     var Controller = RouteData.Values[ "controller" ];     var Action = RouteData.Values[ "action" ];     var Id = RouteData.Values[ "id" ];     string Output = string .Format( "Controller = {0}, Action= {1}, Id= {2}" ,                Controller, Action, Id);     ViewBag.Message = Output;     return View(); }

How to check system installation date in Windows computer?

Image
If you want to check windows installation date, go to command prompt and type the following command. systeminfo | find/i "install date" And you will get something like this.

How use getContentResolver in a class without activity?

In android development, methods like getContentResolver() need context to call these kinds of methods. But some classes does not have  Context. In those cases it is used like this. Application: getApplicationContext()  Activity: this (as Activity extends Context)  Fragment: getActivity()

HTTP Status 405 - HTTP method GET is not supported by this URL

When I'm working with Java Servlet, I encountered "HTTP Status 405" error. But code seems to legit. The problem was, servlet doGet method calling super method. package uk.co.andromedatech.onlineradio; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Test extends HttpServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub super.doGet(req, resp); resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.println("Leann...."); } } After removal of red marked code selection, servlet compiled and started to work.