Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright 2014 Capptain
 * 
 * Licensed under the CAPPTAIN SDK LICENSE (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   https://app.capptain.com/#tos
 *  
 * This file is supplied "as-is." You bear the risk of using it.
 * Capptain gives no express or implied warranties, guarantees or conditions.
 * You may have additional consumer rights under your local laws which this agreement cannot change.
 * To the extent permitted under your local laws, Capptain excludes the implied warranties of merchantability,
 * fitness for a particular purpose and non-infringement.
 */

public class Main {
    /**
     * Build an Capptain alias for an Android Activity class. This implementation takes the simple
     * name of the class and removes the "Activity" suffix if any (e.g. "com.mycompany.MainActivity"
     * becomes "Main").<br/>
     * This method is used by {@link CapptainActivity} and its variants.
     * @return an activity name suitable to be reported by the Capptain service.
     */
    public static String buildCapptainActivityName(Class<?> activityClass) {
        String name = activityClass.getSimpleName();
        String suffix = "Activity";
        if (name.endsWith(suffix) && name.length() > suffix.length())
            return name.substring(0, name.length() - suffix.length());
        else
            return name;
    }
}