All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.parse.PPNSUtil Maven / Gradle / Ivy

Go to download

A library that gives you access to the powerful Parse cloud platform from your Android app.

There is a newer version: 1.17.3
Show newest version
/*
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.parse;

import android.app.Service;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/** package */ class PPNSUtil {
  /* package for tests */ static String CLASS_PPNS_SERVICE = "com.parse.PPNSService";

  public static boolean isPPNSAvailable() {
    try {
      Class.forName(CLASS_PPNS_SERVICE);
      return true;
    } catch (ClassNotFoundException e) {
      return false;
    }
  }

  @SuppressWarnings("TryWithIdenticalCatches")
  public static ProxyService newPPNSService(Service service) {
    try {
      Class clazz = Class.forName(CLASS_PPNS_SERVICE);
      Constructor cons = clazz.getDeclaredConstructor(Service.class);
      return (ProxyService) cons.newInstance(service);
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
      throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
      throw new RuntimeException(e);
    } catch (InstantiationException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy