{"id":13528041,"url":"https://github.com/WithoutInternetTechnology/wit-android-sdk","last_synced_at":"2025-04-01T11:31:01.222Z","repository":{"id":49775927,"uuid":"74052355","full_name":"WithoutInternetTechnology/wit-android-sdk","owner":"WithoutInternetTechnology","description":"WIT Android Edition is a mobile sdk for Native Android Applications that let's mobile developers communicate with their APIs without 3g or WiFi available. ","archived":false,"fork":false,"pushed_at":"2017-03-13T11:42:19.000Z","size":35129,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-02T13:34:13.694Z","etag":null,"topics":["http","http-over-sms","internet","offline","okhttp","sms","wit"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WithoutInternetTechnology.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-17T17:47:13.000Z","updated_at":"2022-07-26T10:39:00.000Z","dependencies_parsed_at":"2022-09-16T16:14:03.165Z","dependency_job_id":null,"html_url":"https://github.com/WithoutInternetTechnology/wit-android-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WithoutInternetTechnology%2Fwit-android-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WithoutInternetTechnology%2Fwit-android-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WithoutInternetTechnology%2Fwit-android-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WithoutInternetTechnology%2Fwit-android-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WithoutInternetTechnology","download_url":"https://codeload.github.com/WithoutInternetTechnology/wit-android-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246631668,"owners_count":20808730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","http-over-sms","internet","offline","okhttp","sms","wit"],"created_at":"2024-08-01T06:02:11.000Z","updated_at":"2025-04-01T11:30:56.213Z","avatar_url":"https://github.com/WithoutInternetTechnology.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"![alt tag](https://raw.githubusercontent.com/WithoutInternetTechnology/wit-android-sdk/master/android-sdk%20banner.png)\n\n# WIT Android SDK *alpha* 0.7.0\n\n*Please be patient :) this is a very early SDK*\n\nWIT Android SDK is a library to give fallback connectivity to mobile Apps.\nUsing WIT SDK you can do any kind of HTTP Requests.\nIf the device is offline, the SMS Channel will be used.\n\nOfficial WIT Android SDK to support:\n\n- Internet backed HTTP Requests based on okHTTP\n- Offline HTTP Requests via WIT Fallback on SMS\n- Android 4.4 (Api 19), 5 and 6\n\n## Generic http offline request\n\nIn the current version WIT SDK supports \"generic requests\" meaning that\nyou can throw(1) any kind of data to any url of choice which can result\nin a big payload being sent via SMS.\nOur system take care of compressing and optimizing the request you are doing.\n\nHere at [WIT Technology](https://www.witsdk.com) we offer a premium support to any company.\nWe can optimize up to 70% the speed of the requests and as a consequence the prices for the data transportation.\nYour endpoints will remain the same so you don't have to modify any code to take\nadvantage of this.\n\n1) we support all HTTP Requests Verbs -\u003e get|post|put|patch|delete\n\n## Contact US\n\nFor any technical issue create it [here](https://github.com/WithoutInternetTechnology/wit-android-sdk/issues) or contact us at davide [ at ] witsdk.com.\nFor business operations, and to know more about our Premium Support write to alessio [ at ] witsdk.com.\n\n## Example\n### [Weather Example using WIT SDK](https://github.com/WithoutInternetTechnology/wit-android-sdk/tree/master/example_projects/WetherExample)\n#### A simple weather app that works without internet\n\u003cimg src=\"example_projects/WetherExample/screenshoots/1.png\" width=\"200\"/\u003e\n\u003cimg src=\"example_projects/WetherExample/screenshoots/2.png\" width=\"200\"/\u003e\n\u003cimg src=\"example_projects/WetherExample/screenshoots/3.png\" width=\"200\"/\u003e\n\u003cimg src=\"example_projects/WetherExample/screenshoots/4.png\" width=\"200\"/\u003e\n\n# Install\n\n### Prerequisites\n\nWIT SDK needs [okHttp3](https://github.com/square/okhttp) to work.\n\n### Setup WIT SDK using Gradle\n\nClone this repository in your project root folder and execute these commands:\n\n```bash\ncd YourProject\ngit clone https://github.com/WithoutInternetTechnology/wit-android-sdk.git\ncp -r ./wit-android-sdk/witsdk witsdk\n```\n\nIn the build.gradle inside your 'app' folder, add WIT SDK and okHttp3:\n\n```java\n    dependencies {\n        compile fileTree(include: ['*.aar'], dir: 'witsdk')\n\n        ...\n        compile 'com.squareup.okhttp3:okhttp:3.4.2'\n        compile project(':witsdk')\n    }\n```\n\nInside your settings.gradle add ':witsdk', the file should look like:\n\n```java\n    include ':app',':witsdk'\n```\n\n## Use it\n\n### Import the WIT SDK\n\n    import com.witsdk.witcore.*;\n\n### Initialize WIT\nIt's recommended to use the same instance ```client``` of the WIT library in the same activity.\nThe constructor ```new Wit(Activity this,FragmentManager fm); ``` takes 2 parameters: ```Activity```  and ```FragmentManager```, this is needed because WIT will handle automatically the permission flow required to use SMS in your app.\n\n```java\npublic class MyActivity extends AppCompatActivity{\n    private Wit client;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        ....\n        FragmentManager fm = getSupportFragmentManager();\n        client = new Wit(this, fm);\n        ...\n    }\n\n    @Override\n    public void onActivityResult(int requestCode, int resultCode, Intent data) {\n        client.onActivityResult(requestCode);\n    }\n\n    @Override\n    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {\n        client.onRequestPermissionsResult();\n    }\n```\n\nThe  ```Activity``` need to override  ```onActivityResult()``` and ```onRequestPermissionsResult()``` has shown in the snipplet above, by doing this the ```Activity``` will be able to intercept the result of asking for SMS permission and communicate the result to ```(Wit) client```.\n\n### Check if the device is connected to the internet.\n```java\nboolean isConnected = client.checkInternetConnection();\n```\n\n### OFFLINE-ONLY Request\nIn order to offer complete flexibility for the developer, this method will perform offline-only request, it will be processed via SMS even if the device has internet connectivity.\nYou can check if the device is connected to the internet by using ```client.checkInternetConnection()```.\n\n```java\n\n    String url = \"http://jsonplaceholder.typicsode.com/posts/1\";\n\n    client.offline_request(url, \"get\", null, new RequestListener() {\n      @Override\n      public void onSuccess(JSONObject json, Integer id) {\n        Log.d(\"WIT REQ\",\"RESPONSE \"+ id.toString() +\" : \" + json.toString());\n      }\n\n      @Override\n      public void onError(int code, String error) {\n        Log.d(\"WIT REQ\",\"ERROR \"+ code +\" : \" + error);\n      }\n    });\n```\n\n### GET Request\nThe http request below will be resolved either using internet or without, providing a consistent way for developer to fetch the data they need without having to worry if the device has internet connectivity.\n\n```java\n\n    String url = \"http://jsonplaceholder.typicsode.com/posts/1\";\n\n    client.request(url, \"get\", null, new RequestListener() {\n      @Override\n      public void onSuccess(JSONObject json, Integer id) {\n        Log.d(\"WIT REQ\",\"RESPONSE \"+ id.toString() +\" : \" + json.toString());\n      }\n\n      @Override\n      public void onError(int code, String error) {\n        Log.d(\"WIT REQ\",\"ERROR \"+ code +\" : \" + error);\n      }\n    });\n```\n### POST Request\n```java\n\n    JSONObject obj = new JSONObject();\n    obj.put(\"id\", 1);\n    obj.put(\"title\", \"foo\");\n    obj.put(\"body\", \"bar\");\n    obj.put(\"userId\", 1);\n\n    client.request(\"http://jsonplaceholder.typicode.com/posts\", \"post\", obj, new RequestListener() {\n        @Override\n        public void onSuccess(JSONObject json, Integer id) {\n            Log.d(\"WIT SDK\",\"POST REQUEST, Response: \"+ id.toString() +\" : \" + json.toString());\n        }\n\n        @Override\n        public void onError(int code, String error) {\n            Log.d(\"WIT SDK\",\"POST REQUEST, Error: \"+ code +\" : \" + error);\n        }\n    });\n```\n### PUT Request\n```java\n    client.request(url, \"put\", obj, new RequestListener() {\n        @Override\n        public void onSuccess(JSONObject json, Integer id) {\n            Log.d(\"WIT SDK\",\"PUT REQUEST, Response: \"+ id.toString() +\" : \" + json.toString());\n        }\n\n        @Override\n        public void onError(int code, String error) {\n            Log.d(\"WIT SDK\",\"PUT REQUEST, Error: \"+ code +\" : \" + error);\n        }\n    });\n```\n### PATCH Request\n```java\n    client.request(url, \"patch\", obj, new RequestListener() {\n        @Override\n        public void onSuccess(JSONObject json, Integer id) {\n            Log.d(\"WIT SDK\",\"PATCH REQUEST, Response: \"+ id.toString() +\" : \" + json.toString());\n        }\n\n        @Override\n        public void onError(int code, String error) {\n            Log.d(\"WIT SDK\",\"PATCH REQUEST, Error: \"+ code +\" : \" + error);\n        }\n    });\n```\n### DELETE Request\n```java\n    client.request(url, \"delete\", null, new RequestListener() {\n        @Override\n        public void onSuccess(JSONObject json, Integer id) {\n            Log.d(\"WIT SDK\",\"DELETE REQUEST, Response: \"+ id.toString() +\" : \" + json.toString());\n        }\n\n        @Override\n        public void onError(int code, String error) {\n            Log.d(\"WIT SDK\",\"DELETE REQUEST, Error: \"+ code +\" : \" + error);\n        }\n    });\n```\n\n### Add HEADERS to your Request\n\nInitialize a Map variable\n\n```java\n  final Map\u003cString, String\u003e headers = new HashMap\u003cString, String\u003e() {{\n        put(\"auth\", \"Password\");\n        put(\"Bearer \", \"auth_token\");\n    }};\n```\n\n```java\n    client.request(url, \"post\", headers, obj, new RequestListener() {\n        @Override\n        public void onSuccess(JSONObject json, Integer id) {\n            Log.d(\"WIT SDK\",\"DELETE REQUEST, Response: \"+ id.toString() +\" : \" + json.toString());\n        }\n\n        @Override\n        public void onError(int code, String error) {\n            Log.d(\"WIT SDK\",\"DELETE REQUEST, Error: \"+ code +\" : \" + error);\n        }\n    });\n```\n\n### Disable Offline Mode\n\nThis function will trigger the system dialog to restore the default SMS app selected before switching to Offline Mode.\n```java\n    client.disableOfflineMode();\n```\n\n### License\n\nCopyright (C) WIT Technology, LTD - All Rights Reserved\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWithoutInternetTechnology%2Fwit-android-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWithoutInternetTechnology%2Fwit-android-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWithoutInternetTechnology%2Fwit-android-sdk/lists"}